I m trying to create a horizontal tab menu. how can i get the combined width of all the li tags and assign the width to the parent UL using jquery?
thanks in advance!
I m trying to create a horizontal tab menu. how can i get the combined width of all the li tags and assign the width to the parent UL using jquery?
thanks in advance!
I d agree with Akoi, I think this is probably one for CSS. Something like
<style type="text/css">
ul { overflow: auto; background: #efefef; padding: 0; margin: 0; display: block; float: left; clear: both; }
ul li { float: left; display: block; padding: 5px 10px; }
</style>
<ul>
<li>Menu item</li>
<li>Menu item</li>
<li>Menu item</li>
<li>Menu item</li>
<li>Menu item</li>
<li>Menu item</li>
</ul>
Out of curiosity, why are you having to specify the width anyways? You should just be able to float your LI s left in css, then clear them with a handy <br />.
<style type="text/css">
ul li { float: left; }
br { clear: both; }
</style>
<ul>
<li>Some</li>
<li>randomly long</li>
<li>or</li>
<li>short</li>
<li>LI s</li>
</ul><br />
here s my html. as you can see, I m only trying to ensure that my ul doesn t extend to the width of the container.
<html>
<head>
<title>Untitled Document</title>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#tabs").tabs();
});
</script>
<style>
#container {width:960px;}
#tabs {background:url(../images/tab_lft.gif) no-repeat 0 0; margin:0 10px; width:940px;}
#tabs ul {background:#ccc url(../images/tab_rgt.gif) no-repeat right 0; height:24px; list-style:none; margin:0 0 0 6px; padding:6px 6px 0 0; }
#tabs ul li {display:inline; float:left; line-height:24px;}
#tabs ul li a:link, #tabs ul li a:visited {display:block; color:#565656; padding:0 10px; text-decoration:none; }
#tabs ul li a:hover {background-color:#fff;}
.clear {clear: both; display: block; overflow: hidden; visibility: hidden; width: 0; height: 0;}
</style>
</head>
<body>
<div id="container">
<div id="tabs">
<ul>
<li><a href="tab1.html">Tab 1</a></li>
<li><a href="tab2.html">Tab 2</a></li>
<li><a href="tab3.html">Tab 3</a></li>
</ul>
<div class="clear"></div>
</div>
</div>
</body>
</html>
I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....
I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.
selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...
How do you target specifically safari in css with styles?
Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...
So I ve got a menu with a hover/selected state and it loads fine in IE6/IE7. However when I scroll down the page and put the element outside of the viewport and then back in I get a broken image! I ...
I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...
I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...