为什么不能在另一个div标签旁边设置Div标签? [英] why cant set Div tag beside another div tag ?

查看:76
本文介绍了为什么不能在另一个div标签旁边设置Div标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.html代码

.html code

<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css"/>

</head>
<body>

	<div class="middle">
			<div class="news">
				<div class="newsheader"align="center">
					
						<p style="text-align:center;"><span style="font-family:Cursive;font-size:18px;font-style:normal;font-weight:bold;text-decoration:none;text-transform:uppercase;color:6633FF;">News And Updates</span>
						</p>
				</div>
				<div class="newscontent" align="center">
					<!--<marquee direction="up">* hiee</marquee>-->
				</div>
			</div><!-- Ending news panel-->
			<div class="igallery">
				Gallery
				
			</div>
			</div><!--middle div over-->
</body>
</html>











.css代码

< br $> b $ b






.css code


.news
{
	height:70%;
	width:27%;
	background:#EEE;
	//border: 3px solid black;
	border-radius:15px;
	margin-top:2%;
	margin-left:1%;
	
	display:relative;
}
.newsheader
{
	border-bottom:3px solid red;
	height:30px;
	//padding-top:3%;
	background:#989898;
	border-radius:15px 15px 0px 0px;
	
}
.footer
{
	height:10%;
	width:100%;
	background:#989898;
	margin-top:50%;
}
.igallery
{
		height:15%;
		width:71%;
		background:red;
		float:left;
		margin-left:29%;
		display:inline;
	
}
.middle
{

	border:3px solid red;
	height:50%;
	width:100%;
	background:green;
	margin-bottom:60%;
	float:left;
}







这里我发布了我的代码我想在另一个div标签旁边设置一个div标签(类名称有igallery)(类名有新闻)。




Here i posted my code i want to set one div tag(class name having igallery) beside another div tag (class name having news).

推荐答案

解决方案



float:left; 添加到 .news

Solution


Add float:left; to .news.
.news
{
    height:70%;
    width:27%;
    background:#EEE;
    //border: 3px solid black;
    border-radius:15px;
    margin-top:2%;
    margin-left:1%;
    float:left;

    display:relative;
}



删除 <击>保证金左:29%; 来自 .igallery


Remove margin-left:29%; from .igallery.

.igallery
{
    height:15%;
    width:71%;
    background:red;
    float:left;
    margin-left:29%;
    display:inline;	
}



演示



[问] Div旁边的另一个分区 [ ^ ]


这篇关于为什么不能在另一个div标签旁边设置Div标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆