Это мой html. Раздел стиля немного отличается, потому что я пишу в React, но в остальном я предполагаю, что моя проблема возникает из-за css и html. Почему внутренние блоки div появляются в нижнем ряду. Я хочу, чтобы он отображался горизонтально внутри внешнего div с прокруткой по оси x. Я уже указывал свойства вроде white-space: nowrap.
<div style = {{position:'absolute', width:'1200px', height:'80px',background:'#cc5',top:'270px',left:'100px',whiteSpace: 'nowrap',display:'inline-block',overflowX:'auto'}}>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
<div style = {{width:'100px',height:'60px',background:'white',display:'inline-block',margin:'10px',float:'left'}}></div>
</div>
да это точно






Поскольку вы используете стиль:
display:'inline-block'
Также у вашего блока кода есть проблема, я исправил для двух div ниже:
<div style = "position:absolute; width:1200px; height:80px;background:#cc5;top:270px;left:100px;whiteSpace: nowrap;display:block;'overflow-x':auto">
<div style = "position:absolute; width:1200px; height:80px;background:#cc5;top:270px;left:100px;whiteSpace: nowrap;display:block;'overflow-x':auto">
Тогда что использовать, чтобы не дошло до новой строки
что использовать тогда ... Я изменил его на встроенный, но даже это не помогает
вы можете использовать display: block
Ваш код требует некоторых изменений, как показано ниже:
<div style = "position: absolute; width: 1200px; height: 80px;background: #cc5;top: 270px;left: 100px;white-space: nowrap;display: inline-block;overflow-x: auto;">
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
<div style = "width: 100px;height: 60px;background: white;display: inline-block;margin: 10px;float: left"></div>
</div>Поскольку у вас есть встроенный стиль, вы можете переместить их в файлы css. Также overflowX нужно поменять на overflow-x.
В ответ мы пишем так camelCase ... в остальном все то же самое
@ J.Doe Тогда вы должны добавить правильный тег к вопросу. Просто [css] недостаточно: то, что у вас есть, не является настоящим css!
ваш код также генерирует тот же результат ... Я имею в виду, что в одной строке у вас есть 9 белых div ... затем 9 в следующей строке и так далее ... я хочу только одну строку, и все элементы продолжаются в одной строке ... и Я получаю их, когда прокручиваю вправо @MrLister
Можете ли вы подтвердить, что используемый стиль представляет собой код React и переводится в фактический HTML в браузере?