How to underline list items separately with CSS? - css

I would like to create some empty space between lines in my list. At the moment the lines are continuous. Here is a jsfiddle example I created: http://jsfiddle.net/bonyhad/pnPDz/8/
Here is the CSS:
#example {
width:800px;
height:220px;
display:block;
overflow:hidden;
margin:0 0 4em 0;
}
#example ul {
list-style:none;
margin:0;
}
#example li {
border-bottom:1px solid #fff;
}
#example h1 {
color:#000;
font-size:20px;
margin-bottom:5px;
}
#example a:link, #example a:visited {
color: #444;
display:block;
border-bottom:1px solid #666;
text-decoration:none;
padding: .3em .25em;
}
.links {
float:left;
width:615px;
margin:0;
padding:0;
}
.links ul {
margin:0;
padding:0;
}
#example .links li {
float:left;
margin 0 20px 0 0;
width:185px;
}
#example .links li:nth-last-child(2),
#example .links li:nth-last-child(3),
#example .links li:nth-last-child(2) a,
#example .links li:nth-last-child(3) a,
#example li:last-child,
#example li:last-child a {
border: 0;
}
And here is the HTML:
<section id="example">
<div class="links">
<h1>links</h1>
<ul>
<li>Example1</li>
<li>Example2</li>
<li>Example3</li>
<li>Example4</li>
<li>Example5</li>
<li>Example6</li>
<li>Example7</li>
<li>Example8</li>
<li>Example9</li>
<li>Example10</li>
<li>Example11</li>
<li>Example12</li>
<li>Example13</li>
<li>Example14</li>
<li>Example15</li>
<li>Example16</li>
<li>Example17</li>
<li>Example18</li>
</ul>
</div>
</section>
Each item on the list should be underlined separately, not as a continuous line.

do this: (update your #example li css to this)
#example li
{
border-bottom:1px solid #fff;
padding:5px;
margin:2px;
}
working fiddle
have a look at box model and mdn

Add a 5px space to the right of each item:
#example li {
margin-right:5px;
}

Related

CSS Menu add title link

I have this CSS for a vertical menu:
#charset "UTF-8";
/* CSS Document */
#vertical_menu {
float:left;
padding-left:10px;
}
#vertical_menu > ul > li {
display:inline-block;
width:250px;
}
#vertical_menu > li {
display:inline-block;
list-style:none;
margin-left:-20px;
}
#vertical_menu li a {
display:block;
padding-bottom:10px;
margin-top:15px;
border-bottom:4px solid #000000;
color: #000000;
text-decoration:none;
text-align:center;
}
#vertical_menu li a:hover {
border-color:#666666;
color:#666666
}
ul {
padding:0px;
margin:0px;
}
how can i make the <li> elements without a a href link different like a menu title so the links below are like a sub menu
here is a fiddle with the full code:http://jsfiddle.net/32hqL/
for example, where it says Link Title, needs to be different like a proper title. maybe centered or something
you can wrap the title in a span and then style the span:
<li><span>LINK TITLE</span></li>
#vertical_menu li span {}
http://jsfiddle.net/peteng/32hqL/4/
http://jsfiddle.net/32hqL/1/
You do it by using:
li:not(a) {
color: red;
}
You can set some style on #vertical_menu li, which will be override with #vertical_menu li a
Demo
try this
http://jsfiddle.net/32hqL/11/
CSS
#charset "UTF-8";
/* CSS Document */
#vertical_menu {
float:left;
padding-left:10px;
}
#vertical_menu > ul > li {
display:inline-block;
width:250px;
}
#vertical_menu > li {
display:inline-block;
list-style:none;
margin-left:-20px;
}
#vertical_menu li a {
display:block;
padding-bottom:10px;
margin-top:15px;
border-bottom:4px solid #000000;
color: #000000;
text-decoration:none;
text-align:center;
font-weight:100;
}
#vertical_menu li a:hover {
border-color:#666666;
color:#666666
}
ul {
padding:0px;
margin:0px;
}
li:not(a) {
color: red;
text-align:center;
font-weight:600;
}
You can define set of styles for link title in separate class and give that class to link title li's. Have a look at working demo here: http://jsfiddle.net/32hqL/9/
.title{
text-align: center;
color: blue;
font-weight: bold;
padding: 5px 0 0 0;
}

CSS Sub Menu shows up outside body

I have tried to find an answer to my question, and while there are similar issues, nothing jumped out as me as a fix for my problem.
I am adding a Sub menu using CSS and for some reason the horizontal sub menu will only show up outside of the body. You can see an example of what happens here http://jsfiddle.net/sxP94/22/.
I need to get the sub menu to appear right under Portfolio on the menu. If anybody could help me figure out why this is happening, I would be ever so grateful.
Here is the code:
CSS
body {
margin:0;
padding:0;
width:100%;
color:#929292;
font:normal 12px/1.5em "Liberation sans", Arial, Helvetica, sans-serif;
}
html, .main {
padding:0;
margin:0;
}
.main {
background:#f8f8f8;
}
a {
color:#0087c7;
text-decoration:underline;
}
.header, .content, .menu_nav, .fbg, .footer, form, ol, ol li, ul, .content .mainbar, .content .sidebar {
margin:0;
padding:0;
}
.header {
}
.header_resize {
margin:0 auto;
padding:0;
width:960px;
}
h1 a, h1 a:hover {
color:#000;
text-decoration:none;
}
h1 span {
}
.menu_nav {
margin:0 auto;
padding:70px 0 0;
height:15px;
float:right;
}
.menu_nav ul {
list-style:none;
padding:0 0 0 1px;
height:15px;
float:left;
background:url(../images/menu_split.gif) no-repeat left center;
}
.menu_nav ul li:first-child {
margin:0;
}
.menu_nav ul li {
margin:0;
padding:0 20px;
float:left;
background:url(../images/menu_split.gif) no-repeat right center;
}
.menu_nav ul li a {
display:block;
margin:0;
padding:0;
font-size:15px;
line-height:18px;
font-weight:bold;
color:#c4c4c4;
text-decoration:none;
text-transform:uppercase;
}
.menu_nav ul li.active a, .menu_nav ul li a:hover {
text-decoration:none;
color:#000;
}
.menu_nav > ul > li > ul {
height:1000px;
left:-99999px;
overflow:visible;
position:absolute;
top:37px;
width:115px;
float: left;
}
.menu_nav > ul > li:hover ul {
left:0;
top:37px;
}
.menu_nav > ul > li > ul > li {
background:none #343434;
border:1px solid #4f4f4f;
float:none;
height:29px;
margin:-1px 0 0;
padding:0 12px;
position:relative;
width:auto;
z-index:1000;
}
.menu_nav ul li ul li a {
color:#ffffff!important;
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
line-height:28px;
text-transform:none;
}
.menu_nav ul li ul li.active a, .menu_nav ul li ul li a:hover {
color:#fff!important;
}
HTML
<body>
<div class="main">
<div class="header">
<div class="header_resize">
<div class="menu_nav">
<ul>
<li class="active"><span>Home</span></li>
<li><span>About</span></li>
<li><span>Services</span></li>
<li><span>Portfolio</span>
<ul>
<li>Boudoir</li>
<li>Babies</li>
<li>Engagement</li>
<li>Wedding</li>
<li>Lifestyle</li>
<li>Family</li>
<li>Grads</li>
</ul>
</li>
<li><span>Blog</span></li>
<li><span>Contact</span></li>
</ul>
</div>
</div>
</div>
</div>
Anytime I change any of the left numbers, the sub menu stops showing up completely. Doesn't even show up on the outside of the body when I hover over the menu. So I can't figure out how to move it around because anything I try makes it disappear completely. Thank you for taking the time to read this and thank you in advance for any help you are able to offer.
Give position: relative to parent of the sub menu. The sub menu is given position:absolute and hence shows up outside.
.menu_nav ul li {
position: relative;
}

Floating a left-aligned horizontal menu in middle

I am having difficulty in getting a menu list to float in the center of it's parent container. Here is the address of the page: simplekitchenandbath.com/staging/
And the necessary code snippets:
div#wrapper {
width:1100px;
margin:0 auto;
padding:0 0 50px 0;
}
div#content-main {
background-color:#000;
width:1024px;
margin:0 auto;
}
nav {
background-color:#000;
height:30px;
}
div#nav-container {
width:720px;
margin:0 auto;
}
ul#nav { position:relative; }
ul#nav li { float: left; zoom: 1; list-style-type:none; margin:0; border-bottom:1px solid #FFF; }
ul#nav a:hover { color:#DDD; text-decoration:none; }
ul#nav a:active { color:#DDD; }
ul#nav li a { display:block; padding:0 10px 0 0; color:#FFF; text-transform:uppercase; }
ul#nav li:last-child a { padding-right:0; }
ul#nav li.hover, ul#nav li:hover { position: relative; }
Make the width smaller and to align it in the center place it inside the container of the element and set its margin to 0 auto; try responsive webdesign with css3 media queries and targeting two different monitor size... because the site on 780px monitor it has the slider to go horizontally.... so basically:
<div class="container">
... some code ...
</div>
css:
.container {
width: 960px;
margin: 0 auto;
}
Thanks for reading... Love to hear some response on my answer.
div#nav-container {
width:575px;
margin:0 auto;
}
the width is too big on #nav-container. set it to 575px !
Use display:inline-block on the #nav element, and text-align:center on the #nav-container

vertical menu in css not formatting correctly

I am trying to show the menu as follows
| HOME |
| GAMES |
| PLAYERS|
|SCHEDULE|
The problem is that my menu is showing like this
| HOME || GAMES |
|PLAYERS||SCHEDULE|
and also.. how can I set the width of it to be consistent?, right now it takes only the length of the word inside of |HOME| but i would like to set this to a fix number.. I am new to css please help
.#tabshor {
width:100%;
font-size:50%;
line-height:5px;
}
#tabshor ul {
margin:-30px;
padding:150px 0px 0px 0px;
line-height:10px;
}
#tabshor li {
display:block;
margin:0;
padding:5;
}
#tabshor a {
float:left;
background:url("../images/tableft.gif") no-repeat left top;
margin:0;
padding:0 0 0 3px;
text-decoration:none;
}
#tabshor a span {
float:left;
display:block;
background:url("../images/tabright.gif") no-repeat right top;
padding:10px 20px 20px 10px;
color:#FFF;
}
#tabshor a span {float:none;}
#tabshor a:hover span {
color:#FFF;
}
#tabshor a:hover{
background-position:0% -42px;
}
#tabshor a:hover span {
background-position:100% -42px;
}
div#tabshor>ul>li {
display:block;
position:relative;
float:left;
list-style:none;
left:50px;
}
div#tabshor>ul>li ul{
position:absolute; display:none;
list-style:none;
left:100px;
}
div#tabshor>ul>li>a{
display:block;
}
div#tabshor>ul>li:hover ul{
display:block;
z-index:500;
width:50%;
margin:10px 0px 0px -20px;
width:100%;
}
div#tabshor ul li ul a{
display:block;
width: 50px;
}
div#tabshor ul li a:hover{
background:red;
font-style: oblique;
}
HERE IS THE HTML
<div id="left_banner" class="divleftside">
<div id="tabshor">
<ul>
<li><span>HOME</span></li>
<li><span>GAMES</span></li>
<li><span>PLAYERS</span>
<ul>
<li><span>PLAYERS</span></li>
<li><span>SOCCER</span></li>
<li><span>BASKETBALL</span></li>
</ul>
</li>
<li><span>COURTS</span></li>
<li><span>REFEREES</span></li>
<li><span>ABOUT US</span></li>
<li><span>CONTACT US</span></li>
<li><span>REGISTER</span></li>
</ul>
</div>
</div>
Try:
Remove float: left from div#tabshor>ul>li
Remove float: left from #tabshor a
Add width: 170px; to div#tabshor>ul>li>a
Cleaning up your CSS might lead to less headaches. Also starting with an example like this vertical rollover list or this nested vertical rollover list might be easier.

Why is this unordered list formatting differently in IE7?

I'm better about getting things to look good in IE8, FF, and Safari, but IE7 still throws curve balls at me...
Please check out this page and scroll down below the nav bar:
http://rattletree.com/instruments.php
It should become obvious when viewing in FF vs IE7. For some reason the formatting of the list is pushing the list items down on the page...
any tips?
<ul class="instrument">
<li class="imagebox"><img src="/images/stuff.jpg" width="247" height="228" alt="Matepe" /></li>
<li class="textbox"><h3>Matepe</h3><p>This text should be to the right of the image but drops below the image in IE7</p></li>
</ul>
css:
ul.instrument {
text-align:left;
display:inline-block;
}
ul.instrument li {
list-style-type: none;
display:inline-block;
}
li.imagebox {
display:inline;
margin:20px 0;
padding:0px;
vertical-align:top;
}
li.imagebox img{
border: solid black 1px;
}
li.textbox {
display:inline;
}
li.textbox p{
margin:10px;
width:340px;
display:inline-block;
}
basically this line ul.instrument li { is overiding li.imagebox etc.
so what you can do is this:
CSS:
ul.instrument {
text-align:left;
display:inline-block;
}
ul.instrument li {
list-style-type: none;
display:inline-block;
}
ul.instrument li.imagebox {
display:inline;
margin:20px 0;
padding:0px;
vertical-align:top;
}
ul.instrument li.imagebox img{
border: solid black 1px;
}
ul.instrument li.textbox {
display:inline;
}
ul.instrument li.textbox p{
margin:10px;
width:340px;
display:inline-block;
}
Basically what I did, instead of declaring li.imagebox I used ul.instrument li.imagebox
so that it won't be overide by this declaration ul.instrument li
Hope this helps :)
Edit, here's another take but this approach is different it uses float
CSS:
ul, li, h3, p { margin: 0; padding: 0 }
ul, li { list-style: none }
ul.instrument { overflow: hidden}
ul.instrument li, ul.instrument li img { float: left; }
ul.instrument li.imagebox { margin:20px 0; }
ul.instrument li.imagebox img { border: 1px solid black }
ul.instrument li.textbox p { margin: 10px; width: 340px }
but this one works in all browsers, I promise :D. Basically the first 2 lines resets the elements you used so that it will look the same in all browser.

Resources