我需要把我的跨度放在一个div内,但是因为div的内容更多,它溢出了父div的边界。 如何解决它? 我的外部div应该是灵活的,因为跨度中的内容是动态的。 这里是plunker链路= DEMO如何把溢出跨度在一个div内
.outerDiv {
width: 100%;
border: 2px solid black;
}
.div40 {
width: 40%;
}
.div60 {
width: 60%;
float: right;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<h1>Hello Plunker!</h1>
<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>
</body>
</html>
您已经定义了'浮动:right'你'div60'即为什么这个问题正在发生,你需要的是清除'float'为:'.outerDiv ::后,.outerDiv ::前{content:“”;显示:表格; } .outerDiv :: after {clear:both; }' – vivekkupadhyay
在你的outerDiv中添加'overflow:auto;'。 – KunJ
@KunJ首先,您的“尝试”解决方案不适合此目的。其次,这里提供的解决方案需要简洁,明确和有用,而不是“尝试”的东西。 –