CSS: How to make the padding-right between li even?
Tags: html,css
Problem :
I have the following simple HTML.
<div>
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</div>
And CSS:
ul { width: 100%; display: flex; flex-direction: row };
I want to make all the <li>
have the same padding-right so that the sum of widths and padding-lefts of all <li>
is equal to <ul>
, like the following:
Total ul length: 100px;
(1st li's width + 1st li's padding-left) +
(2nd li's width + 2nd li's padding-left) +
(3rd li's width + 3rd li's padding-left) == 100px;
so that the 3 <li>
's padding-left are equal.
Can I do this with pure CSS without javascript?
Thank you.
Solution :
Have you tried this:
CSS
ul {
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row nowrap;
flex-flow: row nowrap;
}
ul li {
-webkit-flex: 1 auto;
flex: 1 auto;
}
CSS Howto..
Use this, $(document).ready(function() { $('.button').click(function() { var next = $(this).next('.inner'); next.toggle(); $('.inner').not(next).hide(); }); }); Demo Fiddle Or CSS method, $(document).ready(function() { $('.button').click(function() { var next = $(this).next('.inner'); var cssState =...
Simply adjust your CSS targets to be tab specific: .tab-about h2 { /** ... **/ } .tab-about p { /** ... **/ } .tab-home h2 { /** ... **/ }...
Consider adding an outline, not border http://jsfiddle.net/tarabyte/z9THQ/ span { outline: 2px solid black; } Firefox draws outline between lines. There is a workarond: http://jsfiddle.net/z9THQ/2/ HTML: <p> This is a potentially...
If you want the banner to be inside the wrapper: HTML <div class="wrapper"> <div class="banner"></div> <div class="head"></div> <div class="content"></div> </div> CSS div.banner { float: right; width: 100px; height: 400px; }...
To target Edge, we can make use of -ms-accelerator, as Edge browser is the only Microsoft browser that supports hardware acceleration: @supports (-ms-accelerator:true) { .selector { color: red; } }...
No luck with float:left, because they are always aligned top. Change to display:inline-block; http://jsfiddle.net/HerrSerker/ZEYvk/15/ Note: No whitespace between </div> and <div ...>...
instead of giving opacity 0.3 to all the div, you can set background: rgba(255,0,0,0.3); and then opacity: 1; in the div like this: http://jsfiddle.net/EUUMX/...
You need to create custom bullets with css for this and then use nth-child selector to style them like you want as shown in below snippet. .styled-list { list-style: none;...
There are units displaying elements depending to the screen : vh and vw vh : means viewport hight. ie : height:50vh; will take 50% height of the screen ( and...
Maybe you were thinking of something like this? Fiddle It's not greyscale, but it provides a similar effect. EDIT: Here's a version for Webkit with greyscale using -webkit-filter (still right-to-left...)...
Ok I just worked this out. I just needed to set the table-layout css property to fixed; eg; table.mistro-form { width:100%; table-layout:fixed; } Hope this can save someone else some...
Try adding this and see if it solves the problem... display: inline-table; ...
Unfortunately, the only way I can see you supporting multiple background images is by adding some extra divs to your HTML and changing your CSS a bit: HTML <div id="canvasFrame">...
You need to omit the space between #koolbutton and .active. #koolbutton { /*not active*/ } #koolbutton.active { /*active*/ } ...
Try to change your CSS like this: .main {width:100%; padding:0; margin:0 auto; min-width: 1020px; overflow: hidden;} .slider { background: transparent; margin:0 auto; padding:0; min-height:420px;} .slider .gallery { margin:0 auto; width:980px;...
Firebug is your friend. ...
Based on @GeekyMonkey's answer, I wrote this little snipped you can put somewhere in your less file: .debug(@var) { &:after { content: "@{var}"; font-size: 20px; background-color: #fff; border: 1px solid...
I've figured it out. So I have the <a name="anchor"></a> within my <h3></h3> and it's causing this issue. If I put the anchor tag outside the <h3> it's fine.
Since i found no solution that works for me using css, i used jquery, this is the code i used: $(document).ready(function () { var img_array = ['bg2.jpg' , 'bg1.jpg']; var...
You need to change the existing JS code to this one. $('h1').click(function(event) { $('footer').toggleClass('border'); }); It will show and hide the border when you click the link. Also do not...
According to Spicework’s documentation, addStyle adds a CSS block to the <head> of the HTML page. Because your <td> has its width defined in its style attribute, that width will...
I could do it myself!!! First you have to draw the four corner´s highlights on HTML: <img id="clt" src="img/clt.png" border="0" style="position:absolute;visibility:hidden"></span> <img id="crt" src="img/crt.png" border="0" style="position:absolute;visibility:hidden"></span> <img id="crb"...
Take a look here at this tutorial to learn how to do it. You need to have an element with a fixed width. This can be done with css or...
Include all the variants in the HTML, then use the CSS selector to make them all display: none except the "correct" string, which you make display: block or display: inline...
Demo Fiddle You should add a tabindex to the ul (<ul class="focus" tabindex='0'>), and href attributes to the a, then use the following: $(".focus").keydown(function (e) { if (e.keyCode == 40)...
Try #box-out{ width:300px; height:400px; border:1px solid black; position: relative; } #box-in{ width:300px; height:100px; background:red; position:absolute; bottom:0; } Demo: Fiddle...
Changing display from inline to inline-block should help. #body { #item { position: relative; display: inline-block; } } ...
For resizing, use .resizable() method of jQuery UI For rotation, use jquery-ui-rotatable plugin. .draggable() and .rotatable() apply to .child elements and .resizable() directly to images. <div class="parent"> <div class='child'> <img...
OP, Twitter Bootstrap may be what you're looking for. Bootstrap handles responsive UI quite nicely. The Fluid Grid System doc has more info and examples, but here's the overview: The...
Display your image through the CSS using background-image and apply the extra property background-size to make it fill the container. Here’s a fiddle. HTML <div class="cover" id="1"> <a href="Articles/boy.html"> <span...