Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8539247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:19:08+00:00 2026-06-11T11:19:08+00:00

I’m using superfish with the supersubs plugin plugin for my main navigation. That works

  • 0

I’m using superfish with the supersubs plugin plugin for my main navigation. That works perfect, except of one little problem. Some of the Submenu-ULs contain font-icons, that are embeded in i-tags, others don’t.
I think, the problem is, that the supersub plugin reads the width of the ULs on pageload and the icons aren’t loaded at this point. So the script gets the wrong UL-width, which results in line break, due to the submenu being too small.

Now I’m trying to check, wheter a submenu-Ul contains a font icon or not, and want to add some extra width to the specific UL in case of an icon.

Below you see the supersubs plugin with my code in between, that is not working. The code is placed in the “each”-lop, that reads everey UL including it’s childs and adds some CSS to the elements in order to get the ULs-width.

How do I determine, wheter an UL contains an i-tag?

Thanks
Lukas

// Initialize Supersubs Plugin
function supersubs_init(){
    $(document).ready(function(){
        $("ul.sf-menu").supersubs({
            minWidth:    13,
            maxWidth:    25,
            extraWidth:  1
        });
    });
}

jQuery(function($){

$.fn.supersubs = function(options){
    var opts = $.extend({}, $.fn.supersubs.defaults, options);
    // return original object to support chaining
    return this.each(function() {
        // cache selections
        var $$ = $(this);
        // support metadata
        var o = $.meta ? $.extend({}, opts, $$.data()) : opts;
        // get the font size of menu.
        // .css('fontSize') returns various results cross-browser, so measure an em dash instead
        var fontsize = $('<li id="menu-fontsize">&#8212;</li>').css({
            'padding' : 0,
            'position' : 'absolute',
            'top' : '-999em',
            'width' : 'auto'
        }).appendTo($$).width(); //clientWidth is faster, but was incorrect here
        // remove em dash
        $('#menu-fontsize').remove();
        // cache all ul elements
        $ULs = $$.find('ul');
        // loop through each ul in menu
        $ULs.each(function(i) {
            var $s_ul = $ULs;
            // cache this ul
            var $ul = $ULs.eq(i);
            // get all (li) children of this ul
            var $LIs = $ul.children();
            // get all anchor grand-children
            var $As = $LIs.children('a');
            // force content to one line and save current float property
            var liFloat = $LIs.css('white-space','nowrap').css('float');
            // remove width restrictions and floats so elements remain vertically stacked
            // check if font icons are being displayed and add extra width
            var emWidth = $ul.add ($LIs).add($As).css({
                'float' : 'none',
                'width' : 'auto'
            })
            // this ul will now be shrink-wrapped to longest li due to position:absolute
            // so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
            .end().end()[0].clientWidth / fontsize;
            // add more width to ensure lines don't turn over at certain sizes in various browsers


            // !!! THIS IS NOT WORKING !!!
            if($($ULs + 'i[class^="icon-"]').length != 0){
                emWidth += o.extraWidth + 1.25;
            }
            else{
                emWidth += o.extraWidth;
            }

            // restrict to at least minWidth and at most maxWidth
            if (emWidth > o.maxWidth)       { emWidth = o.maxWidth; }
            else if (emWidth < o.minWidth)  { emWidth = o.minWidth; }
            emWidth += 'em';
            // set ul to width in ems
            $ul.css('width',emWidth);
            // restore li floats to avoid IE bugs
            // set li width to full width of this ul
            // revert white-space to normal
            $LIs.css({
                'float' : liFloat,
                'width' : '100%',
                'white-space' : 'normal'
            })
            // update offset position of descendant ul to reflect new width of parent
            .each(function(){
                var $childUl = $('>ul',this);
                var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right';
                $childUl.css(offsetDirection,emWidth);
            });
        });

    });
};
// expose defaults
$.fn.supersubs.defaults = {
    minWidth        : 13,       // requires em unit.
    maxWidth        : 25,       // requires em unit.
    extraWidth      : 2         // extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
};
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:19:09+00:00Added an answer on June 11, 2026 at 11:19 am

    For the record, this CSS rule may probably had done it. (Untested)

    ul.sf-menu > li [class^="icon-"] {
      display: inline-block;
      width: 1.25em;
    }​
    

    UPDATE

    According to OP, this worked for him:

    ul.sf-menu > li [class^="icon-"] {
      margin-right: 4px;
      display: inline-block;
      vertical-align: baseline;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.