jquery - 水平对齐 div 并 overflow hidden

标签 jquery html css

我试图将列表项与隐藏的溢出水平对齐,并且仅当鼠标位于 div 的边缘时才显示隐藏的元素。实现这一目标的最佳方法是什么?

HTML

<div id="carousel-inner-container">
   <ul id="carousel">
      <li class="carousel-img"></li>
      <li class="carousel-img"></li>
      <li class="carousel-img"></li>
      <li class="carousel-img"></li>
      <li class="carousel-img"></li>
   </ul> 
</div>

CSS

#carousel-inner-container {
   margin: 0 auto;
   max-width: 980px;
   overflow: hidden;
}

#carousel {
    color: #ffffff;
    list-style: none outside none;
    text-transform: uppercase;
    width: 2000px;
}

#carousel li {
    float: left;
    height: 223px;
    position: relative;
    width: 265px;
 }

最佳答案

演示:http://jsfiddle.net/sL8sX/1/ 已更新

li {
    display: inline-block;
    width: 100px;
    height: 100px;
    background-color: hotpink;
    color:white;
    text-align: center;
    line-height: 100px;
}
ul { padding: 0; margin: 0; width: 100px; white-space: nowrap; overflow: hidden; }

li:first-of-type {
    background-color: red;
    position: relative;
}
li:first-of-type span {
    height: 100px;
    width: 10px;
    background-color: purple;
    position: absolute;
    right: 0;
}
.expand {
    width: auto;
}

关于jquery - 水平对齐 div 并 overflow hidden ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24311307/

相关文章:

javascript - 无法读取未定义的属性 'toFixed'。未捕获的类型错误

javascript - jQuery div 掉落效果onload

html - 单行滚动 HTML 列表

javascript - Django /HTML : Send information through a button click?

javascript - 需要帮助关闭可点击的下拉菜单,同时切换不同的目标下拉菜单

javascript - jQuery 无限滚动和砌体问题

javascript - 无法使用 jQuery 从点击范围获得响应

javascript - 如何在三个div之间切换?可能使用 jquery 解决方案?

javascript - UI设计: templates for wizard driven app?

javascript - 如何根据子表样式可见性隐藏父表