gpt4 book ai didi

html - 改变 div 的方向

转载 作者:行者123 更新时间:2023-11-27 23:59:27 26 4
gpt4 key购买 nike

<div>
<p>abcd efgh ijkl mno</p>
</div>

div{
width:400px;
height:200px;
font-size:40px;
}

现在,如果内容的高度大于 div 高度,内容就会垂直从 div 中出来。 div固定宽度为400px,内容不会横向从div中出来。我希望我的内容水平地从 div 中出来。抱歉我的英语不好。

提前致谢。

查看以下fiddle其中内容尊重 div 的宽度……而不是高度。

我想要内容尊重高度的另一种方式。

最佳答案

当您对 JS 解决方案持开放态度时,您可以调整内容的大小,使其变宽直到适合垂直边界:

var bounds = document.getElementById("bounds");
var content = document.getElementById("content");
while(content.offsetHeight>bounds.offsetHeight){
content.style.width = (content.offsetWidth+1)+'px';
}

http://jsfiddle.net/zuaG6/

关于html - 改变 div 的方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22113704/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com