怎么让超出div宽度的元素横向滚动?
设置容器div的css样式
横向滚动 overflow-y:auto;
纵向滚动 overflow-x:auto;
当然你还得设置容器div的宽度。
设置overflow属性试试
设置overflow属性试试
#tar1, #tar2, #tar3 { width: 540px; height: 220px; } #content { width: 560px; height: 220px; overflow: auto; } <div id="content"> <div id="tar1" style="background-image: url(/1.jpg)"> </div> <div id="tar2" style="background-image: url(/2.jpg)"> </div> <div id="tar3" style="background-image: url(/3.jpg)"> </div> </div>
以下是css+html代码,帮忙看看吧.
#tar1, #tar2, #tar3 { width: 540px; height: 220px; } #content { width: 560px; height: 220px; overflow:auto; } <div id="content"> <div id="tar1" style="background-image: url(/funny/1.jpg)"> </div> <div id="tar2" style="background-image: url(/funny/2.jpg)"> </div> <div id="tar3" style="background-image: url(/funny/3.jpg)"> </div> </div>
你图片的宽度都没有超过容器的宽度怎么会出现横向滚动条啊?楼主可以把
#content { width: 560px; height: 220px; overflow:auto; }
#content { width: 460px; height: 220px; overflow:auto; }