Css 如何在div中放置溢出的span
我需要将span放在一个div中,但是因为div的内容更多,所以它溢出了父div的边界。 如何解决? 我的外部div应该是灵活的,因为span中的内容是动态的。 这是plunker链接=Css 如何在div中放置溢出的span,css,html,Css,Html,我需要将span放在一个div中,但是因为div的内容更多,所以它溢出了父div的边界。 如何解决? 我的外部div应该是灵活的,因为span中的内容是动态的。 这是plunker链接= .outerDiv{ 宽度:100%; 边框:2件纯黑; } .第40课{ 宽度:40%; } .60司{ 宽度:60%; 浮动:对; } 你好,普朗克! 你好 您好,我正在尝试将此内容插入父div,但我无法这样做。我的内容应该在这个div的边界内,我希望高度不要固定,因为我的内容是动态的。 将outerD
.outerDiv{
宽度:100%;
边框:2件纯黑;
}
.第40课{
宽度:40%;
}
.60司{
宽度:60%;
浮动:对;
}
你好,普朗克!
你好
您好,我正在尝试将此内容插入父div,但我无法这样做。我的内容应该在这个div的边界内,我希望高度不要固定,因为我的内容是动态的。
将outerDiv设置为显示:内联块
/*样式在这里*/
欧特尔迪夫先生
{
宽度:100%;
边框:2件纯黑;
显示:内联块;
}
.第40课
{
宽度:40%;
}
.60司
{
宽度:60%;
浮动:对;
}
你好,普朗克!
你好
您好,我正在尝试将此内容插入父div,但我无法这样做。我的内容应该在这个div的边界内,我希望高度不要固定,因为我的内容是动态的。
通过将显示内联块添加到外部div类,您可以实现它
/*样式在这里*/
欧特尔迪夫先生
{
宽度:100%;
边框:2件纯黑;
显示:内联块;
}
.第40课
{
宽度:40%;
}
.60司
{
宽度:60%;
浮动:对;
}
.outerDiv span{}
你好,普朗克!
你好
您好,我正在尝试将此内容插入父div,但我无法这样做。我的内容应该在这个div的边界内,我希望高度不要固定,因为我的内容是动态的。
您需要在div60
<div class ="outerDiv">
<span class = "div40">
hello
</span>
<span class = "div60">
hello i am trying to insert this content inside the parent div,but i am not able to do so. My content should be inside the border of this div and i want the height not to be fixed as my content is dynamic.
</span>
<div class="clear"></div>
</div>
移动到流体内容。。。引导
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
</head>
<body>
<h1>Hello Plunker!</h1>
<div class="container">
<div class="row">
<div class="col-md-4">
hello
</div>
<div class="col-md-8">
hello i am trying to insert this content inside the parent div,but i am not able to do so. My content should be inside the border of this div and i want the height not to be fixed as my content is dynamic.
</div>
</div>
</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<script src="https://getbootstrap.com/assets/js/ie10-viewport-bug-workaround.js"></script>
</html>
你好,普朗克!
你好
您好,我正在尝试将此内容插入父div,但我无法这样做。我的内容应该在这个div的边界内,我希望高度不要固定,因为我的内容是动态的。
您已经为div60
定义了float:right
,即为什么会发生此问题,您只需将float
清除为:.outerDiv::after、.outerDiv::before{content:;display:table;}.outerDiv::after{clear:tware;}
添加溢出:auto首先,你的“尝试”解决方案不适合这个目的。其次,这里提供的解决方案需要简洁、清晰和有用,而不是“尝试”什么。你可以让他使用伪clearfix方法来清除float
不确定OP需要支持的浏览器,而不是添加DOM,添加div是最安全的。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
</head>
<body>
<h1>Hello Plunker!</h1>
<div class="container">
<div class="row">
<div class="col-md-4">
hello
</div>
<div class="col-md-8">
hello i am trying to insert this content inside the parent div,but i am not able to do so. My content should be inside the border of this div and i want the height not to be fixed as my content is dynamic.
</div>
</div>
</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<script src="https://getbootstrap.com/assets/js/ie10-viewport-bug-workaround.js"></script>
</html>