我创建了3个div:
我创建了三个标签,我需要在同一行中对齐两个div - 左边的菜单div和右边的显示。
我收到错误,因为我尝试了很多例子,但没有一个能够正常运作。
可能是什么问题,我该如何解决?
HTML
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<title>Blueprint: Vertical Icon Menu</title>
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/leftmenu.css" />
<link rel="stylesheet" type="text/css" href="flaticon.css" />
<script src="js/modernizr.custom.js"></script>
<style>
body {position: relative;font-family: 'Lato', Calibri, Arial, sans-serif; color: #47a3da;}
body, html { font-size: 100%; height: 100%; padding: 0; margin: 0;}
a {color:#f0f0f0;text-decoration: none;}
a:hover {color: #000;}
#footer{height: 50px;background-color: #ddd;width: 100%;}
#header{z-index: 1;top: 0;margin-top: 0px;position: fixed;height: 90px;width: 100%;background-color: #ddd;}
.dis123{width: 500px;height: 500px;background-color: #ddd;text-align: left;
display: block;
margin-left: auto;
margin-right: auto;}
</style>
</head>
<div id="header">
Head
</div>
<body>
<div class="postleftmen">
<ul class="cbp-vimenu">
<li><a href="#" class="">SELECT CATEGORY</a></li>
<li><a href="#" class="flaticon-smart">MOBILE & TABLET</a></li>
<li><a href="#" class="flaticon-pc6">ELECTRONICS & COMPUTER</a></li>
<li><a href="#" class="flaticon-car95">Vehicles</a></li>
<li><a href="#" class="flaticon-livingroom6">Home & Furniture</a></li>
<li><a href="#" class="flaticon-pets3">Pets</a></li>
<li><a href="#" class="flaticon-cd">Books, CDs & Hobbies</a></li>
<li><a href="#" class="flaticon-black276">Clothing & Accessories</a></li>
<li><a href="#" class="flaticon-baby23">Kids & Baby</a></li>
<li><a href="#" class="flaticon-bicycle14">Sports & Health</a></li>
<li><a href="#" class="flaticon-tools6">Services</a></li>
<li><a href="#" class="flaticon-businessman221">Jobs</a></li>
<li><a href="#" class="flaticon-house111">Real Estate</a></li>
</ul>
</div>
<div class="dis123">
display
</div>
<div id="footer">
footer
</div>
</body>
</html>
答案 0 :(得分:0)
您需要使用float:left
属性,在行中显示两个 DIVS 。然后使用clear:both
div
来放置页脚。
<强> HTML 强>
<div id="header">
Head
</div>
<div class="postleftmen">
<ul class="cbp-vimenu">
<li><a href="#" class="">SELECT CATEGORY</a></li>
<li><a href="#" class="flaticon-smart">MOBILE & TABLET</a></li>
<li><a href="#" class="flaticon-pc6">ELECTRONICS & COMPUTER</a></li>
<li><a href="#" class="flaticon-car95">Vehicles</a></li>
<li><a href="#" class="flaticon-livingroom6">Home & Furniture</a></li>
<li><a href="#" class="flaticon-pets3">Pets</a></li>
<li><a href="#" class="flaticon-cd">Books, CDs & Hobbies</a></li>
<li><a href="#" class="flaticon-black276">Clothing & Accessories</a></li>
<li><a href="#" class="flaticon-baby23">Kids & Baby</a></li>
<li><a href="#" class="flaticon-bicycle14">Sports & Health</a></li>
<li><a href="#" class="flaticon-tools6">Services</a></li>
<li><a href="#" class="flaticon-businessman221">Jobs</a></li>
<li><a href="#" class="flaticon-house111">Real Estate</a></li>
</ul>
</div>
<div class="dis123">
display
</div>
<div style="clear:both"> </div>
<div id="footer">
Footer
</div>
<强> CSS 强>
body {position: relative;font-family: 'Lato', Calibri, Arial, sans-serif; color: #47a3da;}
body, html { font-size: 100%; height: 100%; padding: 0; margin: 0;}
a {color:#f0f0f0;text-decoration: none;}
a:hover {color: #000;}
#header{height: 90px;width: 100%;background-color: #ddd;}
#footer
{
height: 50px;width: 100%;background-color: #ddd;
}
.dis123
{
width:60%;
float:left; height: 500px;background-color: #ddd;text-align: left;
}
.postleftmen
{
width:40%;
float:left;
}
<强> DEMO 强>