最后,这将是一个简单的响应式滑块。问题是 li 不会水平堆叠。我如何保持当前窗口宽度为 100% 的 li 和溢出的 ul 水平滚动而不是垂直滚动?是否有可能只在css中加点他的?
这是一个活生生的 JSFIDDLES 示例
html
<article id="viewport">
<ul id="slideshow">
<li class="slide">
<section id="towing">
<div class="caption">
<header>
<h1>towing service</h1>
</header>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum et nisi quam, eget cursus augue. Sed id felis non urna tristique lacinia vel quis neque. Vivamus nisl nibh, lacinia sed egestas et, euismod mollis sem. Maecenas non orci erat, a tincidunt magna.</p>
</div>
</section>
</li>
<li class="slide">
<section id="scraping">
<div class="caption">
<header>
<h1>metal scraping service</h1>
</header>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum et nisi quam, eget cursus augue. Sed id felis non urna tristique lacinia vel quis neque. Vivamus nisl nibh, lacinia sed egestas et, euismod mollis sem. Maecenas non orci erat, a tincidunt magna.</p>
</div>
</section>
</li>
<li class="slide">
<section>
<div class="caption">
<header>
<h1>trade-in service</h1>
</header>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum et nisi quam, eget cursus augue. Sed id felis non urna tristique lacinia vel quis neque. Vivamus nisl nibh, lacinia sed egestas et, euismod mollis sem. Maecenas non orci erat, a tincidunt magna.</p>
</div>
</section>
</li>
</ul>
</article>
CSS(.less 语义对不起)
div#service{
position:relative;
height:800px;
width: 100%;
background:pink;}
article#viewport{
position:relative;
height:600px;
width:100%;
top:100px;
background:@yellow;
overflow:hidden; }
ul#slideshow{
position:relative;
overflow:auto;
height:100%;
display:inline-block; }
li.slide{
position:relative;
height:600px;
width: 100%;
zoom: 1;
display:inline-block;
background:#ccc;
}
div.caption{width:300px; background:#555;text-align:right;float:right;}
</p>
附言。为什么当我将 .captions 设置为绝对位置时;它打破了整个互动?