简体   繁体   中英

<ul><li> wont go horizontal

I have a ul i want to go horizontal but its not working. Heres the code:

html:

<ul id="ul_text">
<li>
<h2>Text</h2>
<p>....</p>
</li>
<li>
<h2>text</h2>
<p>....</p>
</li>
</ul>

CSs:

#ul_text {
list-style-type: none; display:inline; }

#ul_text li{
border-right: 1px solid #ffffff; width:260px; }

However this does not work work! what am i doing wrong?

You can try floating the li elements:

#ul_text li {
  border-right: 1px solid #ffffff; 
  width:260px; 
  float: left;
}

or adding: list-style-type: none; as well as switching display: inline to the li element, as suggested already.

#ul_text li {
  border-right: 1px solid #ffffff; 
  width:260px; 
  display: inline; 
  list-style-type: none;
}

You need to put display: inline on your li instead of the ul, like so:

#ul_text {
  list-style-type: none;
}

#ul_text li {
  border-right: 1px solid #ffffff; 
  width:260px; 
  display:inline;
}

Here is a quick sample: http://css.maxdesign.com.au/listamatic/horizontal01.htm

HTML
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="#" id="current">Item one</a></li>
<li><a href="#">Item two</a></li>
<li><a href="#">Item three</a></li>
<li><a href="#">Item four</a></li>
<li><a href="#">Item five</a></li>
</ul>
</div>

CSS
#navlist li
{
display: inline;
list-style-type: none;
padding-right: 20px;
}

add

float:left;

to

#ul_text {list-style-type:none; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM