[英]how to make to div in same row
I created 3 divs: 我创建了3个div:
I created three tag and I need to align two divs in the same row — the menu div in the left and display in the right. 我创建了三个标签,我需要在同一行中对齐两个div-菜单div在左侧,并在右侧显示。
I am getting error in that I tried many examples and none of them are working. 我尝试了许多示例,但都无法正常工作,因此出现了错误。
What could be the problem, and how can I fix it? 可能是什么问题,我该如何解决?
HTML 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>
You need to use float:left
property two show two DIVS in row. 您需要使用float:left
属性两个在行中显示两个DIVS 。 and then use clear:both
for div
to place footer. 然后使用clear:both
和div
放置页脚。
HTML 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 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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.