html - CSS 并排对齐 UL

标签 html css html-lists

我有两个无序列表,它们的元素是并排的。我很难弄清楚如何将这些列表并排放置。现在它看起来像:

加1加2

加3加4加5

我需要它看起来像这样: 添加 1 添加 2 添加 3 添加 4 添加 5

这是我的 css 和 HTML,包括我一直在使用的 fiddle 。 ul,ol { 列表样式:无;

.product-view .sharing-links a {
  background-image: url(../images/icon_sprite.png);
  background-repeat: no-repeat;
  text-indent: -9999px;
}

.product-essential {margin-bottom:0px; padding-bottom:25px;}
.product-view .product-essential .product-shop .nobr {margin-bottom:5px; display:inline-block;}

.product-view { margin-bottom:20px;}
.product-view .product-shop {float:right;width:100%;}

.add-to-box { background-color: #F4F4F4; border-right: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; }
.add-to-box .add-to-links  { float: left; }

.product-view .add-to-links { margin-left:25px !important; padding: 15px 0 5px;  border-top: 1px solid #DBDBDB; width: 100%; float: left; }
.product-view .sharing-links { float: left; }

.product-view .add-to-links li {margin-bottom: 8px; display:inline-block; }
.product-view .add-to-links li a:before { font-size: 14px; margin-right: 15px; color:#2E8AB8; }
.product-view .add-to-links li .link-wishlist:before { }
.product-view .add-to-links li .link-compare:before { }


.product-view  .sharing-links:after {
  content: '';
  display: table;
  clear: both;
}
.product-view .sharing-links li {
  float: left;
  padding: 0px 7px 7px;
}
.product-view .sharing-links a {
  text-indent: -9999px;
  display: block;
  width: 26px;
  height: 26px;
}
.product-view  .sharing-links a:hover {
  opacity: 0.8;
}
.product-view .sharing-links a.link-email-friend {
  background-position: 0px -322px;
}
.product-view  .sharing-links a.link-facebook {
  background-position: 0px -425px;
}
.product-view  .sharing-links a.link-twitter {
  background-position: 0px -372px;
}

<div class="product-view">
    <div class="product-essential">
        <div class="product-shop">
            <div class="add-to-box">
                <ul class="add-to-links">
                    <li>Add 1</li>
                    <li>Add 2</li>
                </ul>

                <ul class="sharing-links">
                    <li>Add 3</li>
                    <li>Add 4</li>
                    <li>Add 5</li>
                </ul>
            </div>
        </div>
    </div>
</div>

fiddle : http://jsfiddle.net/23y6o7dj/

感谢您的帮助!我确定它很明显:/

最佳答案

你只需要将 width:100% 的值更改为 width:auto 并删除 padding: 15px 0 5px; 属性来自 .product-view .add-to-links CSS 样式:

.product-view .add-to-links { 
     margin-left:25px !important;  
     border-top: 1px solid #DBDBDB; 
     width: auto; 
     float: left; 
}

这是 the working Fiddle .

关于html - CSS 并排对齐 UL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28154347/

相关文章:

html - 在 Powershell 中解析 html 实体

jquery - 可折叠菜单栏

javascript - 向左和向右动画 ui ul - 不是圆形

css - "lower-latin"CSS 属性的 "lower-alpha"和 "list-style-type"值之间有什么区别吗?

javascript - 显示随机选择的列表项并随机播放

javascript - 浏览器忽略覆盖 div 上的 z-index

html - 单个 svg 文件

html - HTML 中的居中列表

javascript - 如果鼠标下的元素只有 "overflow-y: scroll"并且水平滚动,iOS Safari 似乎永远不会触发滚动事件

javascript - @Html.CheckBoxFor() - 更改复选框标签颜色