Damien Golding
Damien Golding

Reputation: 1000

First list item in HTML list appearing slightly too high

I was just starting to make a basic page layout when a problem I couldn't quite grasp came to me again. Why does my page have one list box to the left higher than the others? Any information would be much appreciated. Thanks

<html>

<head>
<style>
body{
background-color:#5187B9;
font-size:120%;
color:#666666;
}
li{
list-style:none;
}
#wrapper{
margin:0 auto;
width:960px;
}
.top{
width:100%;
}
.block01{
clear:both;
background-color:white;
border-radius:4px;
border:1px solid white;
}
.menu{
width:100%;
height:45px;
padding-top:5px;
background-color:#E8EFF6;
}
.menu ul{
height:40px;
margin-left:20px;
}
.menu li{
float:left;
margin-left:5px;
margin-right:5px;
padding:5px;
background-color:#8888F6;
color:#277098;
}
.block02{
clear:both;
width:100%;
color:white;
}
.block02 ul{
width:100%;
clear:both;
color:black;
}
.block02 li{
float:left;
height:300px;
width:120px;
border-radius:4px;
border:1px solid white;
background-color:white;
}
.block02 ul .list02{
margin-left:20px;
margin-right:20px;
}
.block03{
clear:both;
width:100%;
background-color:white;
padding:10px;
}
</style>
</head>

<body>
<div id="wrapper">
<div class="top">
</div>
    <div class="block01">
    <div class="menu">
    <ul>
    <li>ホーム</li>
    <li>特徴</li>
    <li>プラン</li>
    </ul>
    </div>

    </div>

    <div class="block02">
    <ul>
    <li class="list01"></li>
    <li class="list02"></li>
    <li class="list03"></li>
    </ul>
    </div>

    <div class="block03">

    </div>

</div>

</body>
</html>

Upvotes: 1

Views: 1525

Answers (3)

Jean-Michel Dentand
Jean-Michel Dentand

Reputation: 533

Try setting the margin-top to 0 for .block02 ul

Upvotes: 0

hjpotter92
hjpotter92

Reputation: 80639

This is because of the clear property in your CSS.

The clear property indicates which sides of an element's box(es) may not be adjacent to an earlier floating box.

Removing the clear property generates the result you need.

Fiddle

P.S.: I have changed height to 250px.

Upvotes: 2

kennypu
kennypu

Reputation: 6051

remove the clear:both on the .block02 ul

Upvotes: 4

Related Questions