我需要把我的跨度放在一個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首先,您的「嘗試」解決方案不適合此目的。其次,這裏提供的解決方案需要簡潔,明確和有用,而不是「嘗試」的東西。 –