CSS padding to list items only applied in IE 10 - html

I have a list of items I'm putting together to scroll across the screen in a ticker.
I have all the CSS working across all browsers except for one element, padding.
You can see in this fiddle the padding left of 12px only works in IE, not in any other browser.
I've tried messing with just about everything I can think of to get it to work in Chrome/Firefox/Safari to no avail.
Any ideas? Thanks.
http://jsfiddle.net/Gmvmc/3/
<div class="exchange-rates">
Exchange rates $ 1 USD:
<a href="http://finance.yahoo.com/currency-converter/" target="_blank">
<div id="scrollerWrapper">
<ul id="scroller">
<li id="USDJPY">TEST</li>
<li id="USDAUD">TEST</li>
<li id="USDEUR">TEST</li>
<li id="USDGBP">TEST</li>
<li id="USDCHF">TEST</li>
<li id="USDCAD">TEST</li>
<li id="USDSEK">TEST</li>
<li id="USDNOK">TEST</li>
</ul>
</div>
</a>
.exchange-rates
{
background:#eeeeff;
padding:10px 19px 10px 59px;
border:1px solid #222266;
color:#222266;
font-size:1.1em;
border-radius:9px;
margin:0 0 0 0;
}
#scrollerWrapper
{
height:25px;
overflow:hidden;
width:70%;
float:right;
}
#scroller
{
height:100%;
margin:0;
padding:0;
position:relative;
color:#222266;
}
#scroller li
{
float:left;
padding:0 0 0 12px;
list-style-position:inside;
}

Tom, I'm guessing what your really trying to achieve here is some control over the space between the bullet and the text of the LI. If so, your most consistent cross-browser solution would be something like this:
#scroller li
{
float:left;
padding:0 0 0 12px;
list-style-position:inside;
list-style: none;
}
#scroller li:before
{
content: "\2022";
margin-right: 10px;/* space between bullet and text */
}
Strongly recommend using the ISO value for the bullet rather than just a bullet in quotes.
More here: how to reduce default gap between bullet and text in <li>?.

Related

CSS: Make all <li> width from a list the same and take up 100% of available space

I am trying to make the horizontal navigation menu take up all available width from parent element.
I have tried using the display:table and display:table-cell but that did not work.
Other methods such as using overflow and width:auto doesn't work either.
The list is created by Joomla through a menu module.
html
<div id="DivN">
<jdoc:include type="modules" name="position-1" />
</div>
html (When viewing on browser)
<div id="DivN">
<ul class="nav menu nav-pills">
<li class="item-101 current active">
Home
</li>
<li class="item-113">
School Info
</li>
<li class="item-114">
Achievements
</li>
<li class="item-115">
News & Events
</li>
<li class="item-116">
Parents & Carers
</li>
<li class="item-117">
Community
</li>
<li class="item-118">
Contact Us
</li>
</ul>
</div>
css
#DivN{
width:100%;
height:42px;
border-top:1px solid black;
border-bottom:1px solid black;
text-decoration:none;
background-color:black;
text-align:center;
font-size:13px;
font-weight:700;
}
#DivN ul{
list-style:none;
width:100%;
}
#DivN ul li{
display:inline-block;
/*float:left;*/
line-height:22px;
height:32px;
list-style-type:none;
margin:4px;
overflow:hidden;
width:auto;
}
I have already tried numerous ways for the past few days...
Yet none of what is found on the internet works.
I do not know what the classes added by Joomla do, nor do I know where they are.
The navigation bar looks like this: https://www.dropbox.com/s/5sw94euzbsgwvrc/Capture.PNG
When mouse is over a button: https://www.dropbox.com/s/lv73war905ii0rh/2.PNG
How can I get it so the list will take up all available space while they are the same size?
If equal width among the items is important to you, you can float the items to the left and give them a set equal width (this works when you know how many items you have. Alternatively, you can use js to determine the width if you have a variable number of menu items):
#DivN{
width:100%;
height:42px;
border-top:1px solid black;
border-bottom:1px solid black;
text-decoration:none;
background-color:black;
text-align:center;
font-size:13px;
font-weight:700;
}
#DivN ul{
list-style:none;
width:100%;
height: 100%;
padding: 0;
margin: 0;
}
#DivN ul li{
float:left;
line-height:37px;
height:100%;
list-style-type:none;
margin:0;
overflow:hidden;
width: 14.28571428571429%;
cursor: pointer;
}
#DivN ul li:hover{
background-color: gray;
}
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
#DivN ul:before,
#DivN ul:after {
content: " "; /* 1 */
display: table; /* 2 */
}
#DivN ul:after {
clear: both;
}
/**
* For IE 6/7 only
* Include this rule to trigger hasLayout and contain floats.
*/
#DivN ul {
*zoom: 1;
}
Here is a fiddle: http://jsfiddle.net/kZb9C/
Updated to make the cf (clearfix) target your element: http://jsfiddle.net/4LUQe/16/
If you want to use the display: table approach, just remember to use display: table-cell on the <li> elements. Also, use vertical-align: middle if you want to vertically center them. (Note that table and table-cell CSS properties do not work in IE7 and below).
Here's a fiddle with the second approach (table): http://jsfiddle.net/kZb9C/1/
I think You should try to use
display: table
once again (for the nav element) and display: table-row for the ul, and display: table-cell for the li.
If You have any problems, please write, but this method SHOULD work.
Don't be afraid of display: table, it isn't an old table element, but really a great trick to make good layout with validate and semantic HTML. Hope it helps
UPDATE
The same working solution: CSS dynamic horizontal navigation menu to fill up specific width (table behavior)
<style>
div { border:1px solid red; width:400px; height:400px; }
ul { width:100%; height:50px; list-style: none; margin:0; padding:0; text-align: center; }
li { background-color:green; color:White; width:1%; position:relative; display:table-cell; border:solid 1px white; }
</style>
<div>
<ul>
<li>CELL 1</li>
<li>CELL 2</li>
<li>CELL 3</li>
<li>CELL 4</li>
</ul>
</div>

CSS styling table of contents, annoying little details, avoiding kludge

I'm trying to recreate a table of contents in CSS. I've gotten some help here before, but the results are still incorrect, and they involve a lot of kludging. Here is an image comparing the original table of contents with my attempt at recreating it.
As you can see, there is still a problem: "A REVIEW OF THE PRINCIPAL QUESTIONS IN MORALS" wraps after "IN" instead of after "QUESTIONS".
Here is the CSS:
.list li {
position:relative;
overflow:hidden;
width:360px;
}
.list li:after {
font-size:120%;
content:"...............";
text-indent:1px;
display:block;
letter-spacing:40px;
position:absolute;
left:1em;
bottom:0px;
z-index:-1;
font-weight:bold;
}
.list li span {
display:inline;
max-width:100px;
background-color:#fff;
padding-right:12px;
}
.list li .number {
float:right;
font-weight:bold;
padding-left:15px;
}
.two-lines {
text-indent:-.9em;
}
.list .two-lines:after {
text-indent: 1px;
}
.two-lines .number {
bottom:0px;
right:0px;
padding-right: 1.2em;
}
As you can see, this is very messy. A jsfiddle is here.
Does anyone know how to solve the wrapping problem, preferably while cleaning up the CSS, or at least not making it worse than it already is?
I know this is a four year old question, so I doubt this answer is of much use to you anymore, but a simple <br> after "Questions" will fix your wrapping issue.
It seems like your wrapping not aligning exactly with the image are due to differences in fonts and specifically the width of your font, so I don't think there's a cleaner way to achieve that effect in pure css. Since responsiveness or multiuse code doesn't seem to be what you were looking for, a hard-coded solution shouldn't be an issue.
.list li {
position:relative;
overflow:hidden;
width:360px;
}
.list li:after {
font-size:120%;
content:"...............";
text-indent:1px;
display:block;
letter-spacing:40px;
position:absolute;
left:1em;
bottom:0px;
z-index:-1;
font-weight:bold;
}
.list li span {
display:inline;
max-width:100px;
background-color:#fff;
padding-right:12px;
}
.list li .number {
float:right;
font-weight:bold;
padding-left:15px;
}
.two-lines {
text-indent:-.9em;
}
.list .two-lines:after {
text-indent: 1px;
}
.two-lines .number {
bottom:0px;
right:0px;
padding-right: 1.2em;
}
<div style="width: 401px; padding-left: 90px">
<div style="margin:25px 0 200px 0">
<div style="text-align:center;font-size:150%;letter-spacing:.2em;margin-bottom:10px;margin-right:-.2em;">CONTENTS</div>
<ul class="list" style="padding-left:22px;">
<li style="margin:0 0 .6em 0;"><span>EDITOR’S INTRODUCTION</span><span class="number">ix</span>
</li>
<li style="margin:0 0 .5em 0;"><span style="padding-left:.9em;">1. Historical</span><span class="number">ix</span>
</li>
<li style="margin:0 0 .5em 0;"><span style="padding-left:.9em;">2. Epistemology</span><span class="number">xii</span>
</li>
<li style="margin:0 0 .5em 0;"><span style="padding-left:.9em;">3. Epistemology of Morals</span><span class="number">xx</span>
</li>
<li style="margin:0 0 .5em 0;"><span style="padding-left:.9em;">4. Psychology of Morals</span><span class="number">xxvi</span>
</li>
<li style="margin:0 0 .5em 0;"><span style="padding-left:.9em;">5. The Moral System</span><span class="number">xxx</span>
</li>
<li style="margin:0 0 1.5em 0;"><span style="padding-left:.9em;">6. Morals and Theology</span><span class="number">xliii</span>
</li>
<li style="margin:0 0 .5em 0; padding-left:.9em;" class="two-lines"><span>A REVIEW OF THE PRINCIPAL QUESTIONS<br> IN MORALS</span><span class="number" style="padding-left:2em;">1</span>
</li>
<li style="margin:0 0 .5em 0;"><span style="padding-left:.9em;">INDEX</span><span class="number">297</span>
</li>
</ul>
</div>
</div>
You also had a </div> where you should have had a </ul>.

magic gap between top and bottom divs in css menu

firefox is the only browser not showing this magic gap. i don't really understand why this gap is showing up to be honest, i'm assuming some of you have ran into this and there is a simple solution i don't really understand why this gap is showing up to be honest, i'm assuming some of you have ran into this and there is a simple solution
here is my css menu code here is my css menu code here is my css menu code
#tabs {
font: bold 11px/1.5em Verdana;
float:left;
width:800px;
height:35px;
background:#FFFFFF;
font-size:93%;
line-height:normal;
}
#tabs ul {
margin:0;
padding:7px 10px 0 10px;
list-style:none;
}
#tabs li {
display:inline;
margin:0;
padding:0;
}
#tabs a {
float:left;
background:url("images/tableft14.gif") no-repeat left top;
margin:0;
padding:0 0 0 4px;
text-decoration:none;
}
#tabs a span {
float:left;
display:block;
background:url("images/tabright14.gif") no-repeat right top;
padding:5px 15px 4px 6px;
color:#666;
}
/* Commented Backslash Hack hides rule from IE5-Mac \*/
#tabs a span {float:none;}
/* End IE5-Mac hack */
#tabs a:hover span {
color:#000;
}
#tabs a:hover {
background-position:0% -42px;
}
#tabs a:hover span {
background-position:100% -42px;
}
This is the css code thats below the menu div
#main-lower {
height: 700px;
background-color:white;
}
#specials {
background-color:#F0F0F0;
width: 870px;
height: 100%;
float: left;
border:1px solid #e2e2e2;
-webkit-border-top-left-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-bottomleft: 10px;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
i don't really understand why this gap is showing up to be honest, i'm assuming some of you have ran into this and there is a simple solution
stright from source code
<div id="tabs">
<ul>
<li><a href='http://' title=''><span>New Deals</span></a></li><li><a href='http://' title=''><span>Liquor</span></a></li><li><a href='http://' title=''><span>Beverages</span></a></li><li><a href='http://' title=''><span>General</span></a></li><li><a href='http://' title=''><span>Fountain Drinks</span></a></li>
</ul>
</div>
Quite often you get "mysterious gaps" on lists if you have new lines between the <li> elements.
<ul>
<li></li>
<li></li>
<li></li>
</ul>
Throw them on one line to see if that gets rid of your gap.
<ul><li></li><li></li><li></li></ul>
If that works then this is a duplicate of: Unwanted margin in inline-block list items
Since your gap is below your list you will want to inspect the css display for the item below it and possibly remove lines there as well. But without seeing your html this may not be the issue at all!
For an explanation on why gaps show up on inline elements see here:
http://css-tricks.com/fighting-the-space-between-inline-block-elements/
Excerpt:
This isn't a "bug" (I don't think). It's just the way setting elements
on a line works. You want spaces between words that you type to be
spaces right? The spaces between these blocks are just like spaces
between words. That's not to say the spec couldn't be updated to say
that spaces between inline-block elements should be nothing, but I'm
fairly certain that is a huge can of worms that is unlikely to ever
happen.
Changed the padding top to 8px from 7px ->> padding:8px 10px 0 10px;
yea, i was pretty sure my html had nothing to do with it, and it wasn't a spacing problem cause i'm using php to call my li's

Reduce a white gap between two <hr> tags

I have the following menu
The two lines are both 'hr' tags and the menu is a div containing a ul. I have been googling for a while now and trying adjusting the css with margin and padding but I want to reduce the white space between the lines and the text bringing them closer to the text.
HTML:
<hr id="header_line"/>
<div id="menu_bar">
<ul>
<li>Add new Form</li>
<li>View old forms</li>
<li>Reports</li>
<li>Site Administration</li>
</ul>
</div>
<hr id="under_menu_line"/>
CSS:
#menu_bar ul {
list-style:none;
padding-left:0px;
}
#menu_bar ul li {
display:inline;
padding-left:10px;
}
#menu_bar ul li a {
text-decoration:none;
color:Black;
font-family:Century Gothic;
font-size:12pt;
}
#menu_bar ul li a:hover {
color:#007C5A;
}
#header_line {
margin-top:5px;
}
#under_menu_line {
margin-top:5px;
}
Any ideas?
The best solution would be to drop the <hr>s, and use border-top and border-bottom in conjunction with padding on the div.
<hr> should be used as a horizontal rule. For instance, a hard separation of paragraphs or a long break. And not as a visual element.
Just like with any other element, the <hr> is controlled by CSS. The space you want to control is just the margin. This is the default from Firefox:
hr {
-moz-box-sizing: border-box;
-moz-float-edge: margin-box;
border: 1px inset;
color: gray;
display: block;
height: 2px;
margin: 0.5em auto;
}
So, the following will make the space 0.1em instead of 0.5em:
hr { margin: 0.1em auto; }
Try this and tell me if this is what you wanted.
#header_line { margin-top:5px; margin-bottom:-10px;}
#under_menu_line { margin-top:-10px; }
Use
#header_line{
margin-bottom:0px;
}
#under_menu_line{
margin-top:0px;
}

HTML/CSS - Remove spaces from line breaks in code for LI

Hey,
Is there a way to get browsers to ignore line breaks in the source?
<div id="navbar">
<div id="navbar-container">
<ul>
<li>HOME</li>
<li>TUTORIALS</li>
<li>BLOG</li>
<li>FORUMS</li>
<li>LINKS</li>
<li> </li>
</ul>
</div>
</div>
#navbar {
background:#FFF;
width:940px;
margin:auto;
border-radius: 10px 10px;
-webkit-box-shadow: 5px 5px 10px #888;
}
#navbar-container {
margin:auto;
}
#navbar-container ul {
list-style:none;
text-align:center;
display:block;
width:auto;
padding:0;
margin:0;
}
#navbar-container li{
list-style:none;
border-left:3px solid black;
display:inline-block;
font-family:"Arial", sans-serif;
font-size:2em;
padding:0 7px 0 10px;
margin:0;
white-space:nowrap;
}
#navbar-container li:hover{
color:#FFF;
background:#000;
border-left:3px solid black;
display:inline-block;
font-family:"Arial", sans-serif;
font-size:2em;
margin:0;
padding:0 7px 0 10px;
}
It's placing a small space between each LI, I've set it up so then line up horizontally,
i could just remove the line breaks in the source, but id prefer not to.
You can float them (either left or right), or you can comment-out the spaces:
<ul>
<li>...</li><!--
--><li>...</li>
</ul>
Or simply leave the tags open 'til the next line.
<ul>
<li>...</li
><li>...</li
><li>...</li>
</ul>
IE seems to do that as a hold-over from the days when list items did not have closing tags. A common way around that is to put the closing > on the next line, i.e.
<ul>
<li>HOME</li
><li>TUTORIALS</li
><li>BLOG</li
>etc...
All browsers should totally ignore whitespace. Is there a particular browser giving you trouble?
Try:
li { margin: 0; padding: 0 }
I was wondering the same thing and what worked for me was:
li { display: table-cell; }
All breaks are ignored and now my menu buttons are right next to each other.
You can see a live example here on my music site: http://www.yanike.tk
I used a CSS Sprite on my UL LI for my navigation menu (home, media,...).