{"id":62,"date":"2019-03-19T11:52:02","date_gmt":"2019-03-19T06:22:02","guid":{"rendered":"https:\/\/www.onlinenote.in\/jquery\/?p=62"},"modified":"2019-03-19T11:52:02","modified_gmt":"2019-03-19T06:22:02","slug":"adjust-li-width-fit-with-ul-width-of-the-outer-div-body","status":"publish","type":"post","link":"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/","title":{"rendered":"Adjust li width fit with ul width of the outer div\/body"},"content":{"rendered":"<p>HTML:-<\/p>\n<pre class=\"lang:default decode:true\">&lt;nav role='navigation'&gt;\r\n  &lt;ul&gt;\r\n    &lt;li&gt;&lt;a href=\"#\"&gt;Home&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;li&gt;&lt;a href=\"#\"&gt;About&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;li&gt;&lt;a href=\"#\"&gt;Home&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;li&gt;&lt;a href=\"#\"&gt;About&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;li&gt;&lt;a href=\"#\"&gt;Clients&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;li&gt;&lt;a href=\"#\"&gt;Contact Us&lt;\/a&gt;&lt;\/li&gt;\r\n  &lt;\/ul&gt;\r\n&lt;\/nav&gt;<\/pre>\n<p>CSS:-<\/p>\n<pre class=\"lang:default decode:true \">* {\r\n  box-sizing:border-box;\r\n}\r\nul {\r\n  width:700px;\r\n  margin:10px auto;\r\n  text-align:center;\r\n}\r\nli {\r\n  list-style:none;\r\n  float:left;\r\n  border:1px solid red;\r\n  padding:10px 0;\r\n}\r\na {\r\n  background:lightgrey;\r\n  display:block;\r\n}<\/pre>\n<p>JavaScript:-<\/p>\n<pre class=\"lang:default decode:true \">(function( $ ){\r\n  $.fn.autowidth = function() {\r\n    return this.each(function() {        \r\n        $('li', this).css({'width' : (100 \/ $('li', this).length) + '%'})\r\n    });\r\n  };\r\n})( jQuery );\r\n\r\n$(document).ready(function(){\r\n    $('nav &gt; ul').autowidth();    \r\n});\r\n<\/pre>\n<p>&nbsp;<br \/>\n<script async src=\"\/\/jsfiddle.net\/manukmsv\/sfbrnt53\/embed\/\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTML:- &lt;nav role=&#8217;navigation&#8217;&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;Home&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;About&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;Home&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;About&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;Clients&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;Contact Us&lt;\/a&gt;&lt;\/li&gt; &lt;\/ul&gt; &lt;\/nav&gt; CSS:- * { box-sizing:border-box; } ul { width:700px; margin:10px auto; text-align:center; } li { list-style:none; float:left; border:1px solid red; padding:10px 0; } a { background:lightgrey; display:block; } JavaScript:- (function( $ ){ $.fn.autowidth = function() { return [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[13,2,12,11],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.10 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Adjust li width fit with ul width of the outer div\/body - jQuery<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adjust li width fit with ul width of the outer div\/body - jQuery\" \/>\n<meta property=\"og:description\" content=\"HTML:- &lt;nav role=&#039;navigation&#039;&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Home&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Home&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Clients&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact Us&lt;\/a&gt;&lt;\/li&gt; &lt;\/ul&gt; &lt;\/nav&gt; CSS:- * { box-sizing:border-box; } ul { width:700px; margin:10px auto; text-align:center; } li { list-style:none; float:left; border:1px solid red; padding:10px 0; } a { background:lightgrey; display:block; } JavaScript:- (function( $ ){ $.fn.autowidth = function() { return [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/\" \/>\n<meta property=\"og:site_name\" content=\"jQuery\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-19T06:22:02+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/\",\"url\":\"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/\",\"name\":\"Adjust li width fit with ul width of the outer div\/body - jQuery\",\"isPartOf\":{\"@id\":\"https:\/\/www.onlinenote.in\/jquery\/#website\"},\"datePublished\":\"2019-03-19T06:22:02+00:00\",\"dateModified\":\"2019-03-19T06:22:02+00:00\",\"author\":{\"@id\":\"\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.onlinenote.in\/jquery\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Adjust li width fit with ul width of the outer div\/body\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.onlinenote.in\/jquery\/#website\",\"url\":\"https:\/\/www.onlinenote.in\/jquery\/\",\"name\":\"jQuery\",\"description\":\"Code Snippets\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.onlinenote.in\/jquery\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Adjust li width fit with ul width of the outer div\/body - jQuery","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/","og_locale":"en_US","og_type":"article","og_title":"Adjust li width fit with ul width of the outer div\/body - jQuery","og_description":"HTML:- &lt;nav role='navigation'&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=\"#\"&gt;Home&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=\"#\"&gt;About&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=\"#\"&gt;Home&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=\"#\"&gt;About&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=\"#\"&gt;Clients&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=\"#\"&gt;Contact Us&lt;\/a&gt;&lt;\/li&gt; &lt;\/ul&gt; &lt;\/nav&gt; CSS:- * { box-sizing:border-box; } ul { width:700px; margin:10px auto; text-align:center; } li { list-style:none; float:left; border:1px solid red; padding:10px 0; } a { background:lightgrey; display:block; } JavaScript:- (function( $ ){ $.fn.autowidth = function() { return [&hellip;]","og_url":"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/","og_site_name":"jQuery","article_published_time":"2019-03-19T06:22:02+00:00","twitter_card":"summary_large_image","twitter_misc":{"Written by":"","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/","url":"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/","name":"Adjust li width fit with ul width of the outer div\/body - jQuery","isPartOf":{"@id":"https:\/\/www.onlinenote.in\/jquery\/#website"},"datePublished":"2019-03-19T06:22:02+00:00","dateModified":"2019-03-19T06:22:02+00:00","author":{"@id":""},"breadcrumb":{"@id":"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.onlinenote.in\/jquery\/adjust-li-width-fit-with-ul-width-of-the-outer-div-body\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.onlinenote.in\/jquery\/"},{"@type":"ListItem","position":2,"name":"Adjust li width fit with ul width of the outer div\/body"}]},{"@type":"WebSite","@id":"https:\/\/www.onlinenote.in\/jquery\/#website","url":"https:\/\/www.onlinenote.in\/jquery\/","name":"jQuery","description":"Code Snippets","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.onlinenote.in\/jquery\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":""}]}},"_links":{"self":[{"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/posts\/62"}],"collection":[{"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":1,"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/posts\/62\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onlinenote.in\/jquery\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}