I'm trying to make a horizontal list where each of the <li>s in the list have a height of 385px and a width of 400px.
I tried making the list horizontal by using inline-block, but that doesn't seem to be working.
By which, I mean the list is still vertical. The <li>s are the right size, but the list is not horizontal.
How can I make this list horizontal? (Preferably without flexbox)
Here is my CSS:
html, body{
margin:0;
padding:0;
font-family:'Open Sans', sans-serif;
font-size:16px;
}
#slides{
list-style:none;
list-style-type:none;
}
#slides li{
height:385px;
width:400px;
display:inline-block;
}
and my HTML:
<form action="" method="get">
<fieldset>
<ul id="slides">
<div id="first">
<li>
1
</li>
</div>
<div id="second">
<li>
2
</li>
</div>
<div id="last">
<li>
3
</li>
</div>
</ul>
</fieldset>
</form>
You are making it totally wrong, you are using div which are block level element, also you cannot use any other element except li inside ul, so your markup is invalid, instead do it like this
<ul>
<li><div>A</div></li>
<li><div>B</div></li>
</ul>
<style>
ul li {
display: inline-block;
}
</style>
Add a float:left to #slides li
#slides li{float:left;}
Hope this helps.
Remove the divs and float the lis to the left:
HTML
<form action="" method="get">
<fieldset>
<ul id="slides">
<li id="first">1</li>
<li id="second">2</li>
<li id="third">3</li>
</ul>
</fieldset>
</form>
CSS
html, body{
margin:0;
padding:0;
font-family:'Open Sans', sans-serif;
font-size:16px;
}
#slides{
list-style:none;
list-style-type:none;
}
#slides li{
height:385px;
width:40px;
display:inline-block;
float: left;
}
http://jsfiddle.net/X6LkZ/1/
Related
This question already has answers here:
Why does margin-top work with inline-block but not with inline?
(3 answers)
Closed 8 years ago.
Im trying to give some margin-top to my .links li a, but its not working, I give this margin but the links stay also without margin.
Do you see why this can be happening?
Here I have my problem:
http://jsfiddle.net/dG6wn/2/
My html:
<div id="content">
<h2>Title</h2>
<span id="date">22/05/2014</span> <br />
<img class="img" src="../image1.jpg"/>
<p>
Paragraph text
</p>
<div id="downloads">
<h3>Links:</h3>
<ul class="links">
<li>Link bigger</li>
<li>Link</li>
<li>Link 3</li>
</ul>
</div>
<span class="back">Back</span>
</div>
My css:
.links li a
{
text-decoration:none;
background:red;
color:#000;
margin-top:20px;
margin:0 auto;
}
try adding
position: relative;
display: inline-block; /* might need this too */
reorder the margin styles. set display to inline-block.
.links li a
{
text-decoration:none;
background:red;
color:#000;
margin:0 auto;
margin-top:20px;
display: inline-block;
}
updated http://jsfiddle.net/dG6wn/3/
Hello I am trying to make a website but my menu bar is not doing what it should. This is what it should look like:
http://i.stack.imgur.com/KDvwo.png
But instead it looks like this:
http://i.stack.imgur.com/Y1Ya8.png
Here is my code:
HTML
<div class="wrapper">
<header>
<h1>Colve</h1></div>
<nav>
<ul class="menu1">
<li><a class="button" href="#">Home</a></li>
<li><a class="button" href="#about">About</a></li>
<li><a class="button" href="#downloads">Downloads</a>
<li><a class="button" href="invasion.html">INVASION</a></li>
</li><li><a class="button" href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<section id="about">
<h1>About-Colve</h1>
<p>Colve is a company that gives you the things you want in one place</p>
<p>Created by Bradley Beeke</p>
</section>
</div>
CSS
html {
font:12pt Lato, sans-serif;
min-height:100%;
background-image:linear-gradient(45deg,#3498db,#2ecc71);
}
body{margin:0px;}
header{
background-color:white;
Color: #FFDF00;
float:left;
padding-left:5px;
display:block;
}
nav {
background-color:white;
float:right;
padding-right:5px;
height:60px;
display:block;
width:100%;
float:right;
}
nav a {
text-decoration:none;
list-style:none;
color:#FFDF00;
font-size:20px;
padding:8px;
}
nav li:hover, a:hover {color:#998100;}
li{display:inline;}
section { margin-bottom: 1000px; padding-top: 150px; float: left; }
Please can you help me!
Working DEMO
<div class="wrapper">
<header>
<h1>Colve</h1> <!-- remove the </div> present here -->
<nav>
<ul class="menu1">
<li><a class="button" href="#">Home</a></li>
<li><a class="button" href="#about">About</a></li>
<li><a class="button" href="#downloads">Downloads</a>
<li><a class="button" href="invasion.html">INVASION</a></li>
</li><li><a class="button" href="contact.html">Contact</a></li>
</ul>
</nav>
In the nav css, make width to be auto
nav {
background-color:white;
float:right;
padding-right:5px;
height:60px;
display:block;
width:auto;
float:right;
}
Add width: 100%; in header {} because currently the header is not properly aligned.
The HTML is not well constructed. Please remove the extra and from the code.
Well, right off the bat your HTML is invalid.. I see two immediate problems.
First, the closing tag after your closing H1 tag cannot be there (it looks like that was just an accident anyway).
<div class="wrapper">
<header>
<h1>Colve</h1></div>
Second, the closing that starts this line doesn't make any sense.. Remove it.
</li><li><a class="button" href="contact.html">Contact</a></li>
Oh, I lied.. there's a 3rd.. There's no closing tag for this element.
<li><a class="button" href="#downloads">Downloads</a>
Other than that, your HTML looks fine to me at a quick look, but in the future you may want to bookmark this site:
http://validator.w3.org/#validate_by_input
After you correct those problems with your HTML, update your question if you're still having problems.
I have a div whose height span 2 rows. But I want to the following div fit into the bottom left and bottom right corner:
http://jsfiddle.net/netnet/NNH6V/
before browse, please drag the splitter to left and you will see the checkbox2 and "2222222222" could be fit into bottom left and bottom right perfectly.
I can use the relative position(.VerticalUp class). But the problem is it will leave a empty row underneath, which I don't want.
Any idea?
If you are trying to float the Hematology div, you have two of them that are causing conflict. If you change .Hematology { float: right; }, this will make the Prenatal content float right...making everything fit...
try float with position.
ps-i'm new here. don't have much experience. :)
Hey now change to your code as like this because your code is difficult i have created new code please check it. and implement your projects according design
Css Code
.top, .bottom{
list-style:none;
color:#fff;
}
.top li, .bottom li{
display:inline-block;
background:green;
width:33%;
vertical-align: top;
border-top:solid 10px red;
}
p{
display:inline-block;
vertical-align: top;
}
.bottom {
position:absolute;
left:0;
right:0;
bottom:0;
}
.bottom li:last-child{
float:right;
}
HTML code
<ul class="top">
<li>
<input type="checkbox">
<p>first Check box</p>
</li>
<li>
<input type="checkbox">
<p>Second Check box</p>
</li>
<li>
<p>finel box</p>
</li>
</ul>
<ul class="bottom">
<li>
<input type="checkbox">
<p>first Check box</p>
</li>
<li>
<p>finel box</p>
</li>
</ul>
Live demo http://jsfiddle.net/fAkY5/
I am prototyping a Wordpress template and I'm trying to place the same elements on the header like this: http://dl.dropbox.com/u/768097/about.pdf
Here are the HTML and CSS files: http://acreedy.oliveandpickle.com/
I need 4 columns in the header and everything should be placed under the images.
HTML:
<div id="header">
<h1>Alan Creedy</h1>
<ul id="quickInfo">
<li class="mission">Mission Statement</li>
<li>Helping People Think for Themselves</li>
<li>1.919.926.0688</li>
<li>Email Me</li>
</ul>
<ul id="menu">
<li class="current">Home</li>
<li>About</li>
<li>Best Practice Ideas</li>
<li>Management Tools</li>
<li>Preneed</li>
<li>Case Studies</li>
<li>Recommended Resources</li>
<li>Think Tank Forum</li>
</ul>
</div>
CSS:
#header {
border-bottom:3px solid #1582AB;
height:200px;
margin:0 auto;
padding:46px 0 0;
width:1000px;
position:relative;
}
#header h1 {
background:url("images/alan_creedy_headshot_transparent.png") no-repeat left top;
font-size:40px;
height:140px;
padding:8px 0 0 215px;
margin:0;
}
#quickInfo {
position:absolute;
right:10px;
top:10px;
width:400px;
}
#quickInfo li {
list-style-type:none;
}
.mission {
font-size:18px;
}
#menu {
margin:0 auto;
padding:0;
width:1000px;
}
Floating left will most certainly fix your issue, though keep in mind whenever you add padding or margin to your floated element that you will have to adjust your width as well. I checked out your page and you didn't compensate that change. Fix the width accordingly and you should be good to go :D
~ Chris
http://twitter.com/TheCSSGuru
If you're using html5 then you could use aside or section elements instead of div's.
<style>
.column {
float: left;
width: 200px;}
</style>
<aside class="column">
Column1
</aside>
<section class="column">
Column2
</section>
<section class="column">
Column3
</section>
<section class="column">
Column4
</section>
I'm building a page that has a UL list with its items floated to create 2 columns. See http://epraxadev.com/valencia/food_truck_festival/index2.php
It works perfectly in Firefox, Chrome, Safari, IE8, and IE7. The only problem is in IE6. In IE6, instead of the list elements stacking in neat 2-row columns, with the thumbnail floated to the left and the description of the thumbnail floated to the right, the description somehow magically clears the floated thumbnail. Odd!
Here's the markup
<ul id="theTrucks">
<li>
<a class="thumb"><img src="images/trucks/dim-sum.png" width="78" height="79" alt="Dim Sum" /></a>
<div class="details">
<p>The Dim Sum Truck brings ample amounts of steamed shu mai and har gow dumplings, baked BBQ pork buns and more.</p>
<ul>
<li>Website »</li>
<li>Facebook »</li>
<li>Twitter »</li>
</ul>
</div>
</li>
<li>
<a class="thumb"><img src="images/trucks/border-grill.png" width="78" height="79" alt="Border Grill" /></a>
<div>
<p>The Border Grill Truck serves gourmet tacos, quesadillas, ceviches and more.</p>
<ul>
<li>Website »</li>
<li>Facebook »</li>
<li>Twitter »</li>
</ul>
</div>
</li>
<li class="clear"></li>
...repeats
And here's the CSS:
<style type="text/css">
ul#theTrucks { margin:1em 0 0; padding:0; }
ul#theTrucks li { width:320px; float:left; display:inline; margin-right:11px; list-style:none; overflow:hidden; }
ul#theTrucks li a.thumb { float:left; display:inline; width:78px !important; height:79px; margin:0; }
ul#theTrucks li div { width:230px; float:left; display:inline; padding:0; margin:0 0 0 11px; }
ul#theTrucks li div p { margin-bottom:0.5em; font-size:11px; line-height:1.2; }
ul#theTrucks li div ul { padding:0; margin:0; list-style:none; font-size:11px; line-height:1.2; }
ul#theTrucks li ul li { list-style-type:none; margin:0; }
ul#theTrucks li.clear { width:100%; float:none; display:block; margin:0; height:50px; clear:both; }
</style>
<!--[if lte IE 6]>
<style type="text/css">
ul#theTrucks li div { width:100px; clear:none; }
</style>
<![endif]-->
Note the IE6-specific style that makes the div only 100px, so I know it's not because the containing li (at 320px) is too small to contain it.
Figured out the problem. The innermost unordered-list <li> tags were inheriting the width of the container <li> tags, which was 320px. I set the inner <li>s like so:
ul#theTrucks li ul li { width:230px; margin:0; }
and ta da! No more alignment issues =D
http://www.thedimsumtruck.com/Index/Home.html is a frigging mess! You can barely scroll the page in IE8.