微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 显示2列中的列表项

如果你运行下面的代码片段或[js小提琴 https://jsfiddle.net/3xdfwsk7/1/],如果我们鼠标悬停在第二张图像上,你可以看到apple1到apple 12的值.但我想在一列中显示苹果1-苹果7,在另一列中显示苹果8到苹果12.

现在:

enter image description here

我需要的是:

enter image description here

#narrow-by-list { display :none;}
.choose1 
{ 
text-transform: capitalize; 
text-align: center;
font-weight:bold;
font-size:18px;
color: #000000;
}
.links1234 { color : #908983;}
.links1234:hover { color : #f85700;}


.grow {
  padding: 5px 5px 5px 5px;
  border-radius: 10px;
  width: 23%;
  margin: 5px 1% 5px 1%;
  float: left;
  position: relative;
  transition: height 0.5s;
  -webkit-transition: height 0.5s;
  text-align: center;
  background-color : #fff;
  
}
.grow:hover ul{
  display: block;
}

.grow ul {
  margin: 0;
  padding: 5px;
  list-style: none;
  display: none;
  position: absolute;
  z-index: 1;
  background: #fff;
  Box-shadow: 0 0 5px 1px rgba(0,.25);
  left: 0;
  right: 0;
}

.grow img{
  width: 100%;
}

.expand 
{
	position:relative;
	right:8px;
	top:4px;
}
<div class="grow">
  <img class = "expand" src="http://sbdev2.kidsdial.com:81/media/cases/apple.png" onmouSEOver="this.src='http://sbdev2.kidsdial.com:81/media/cases/apple_active.png'"
onmouSEOut="this.src='http://sbdev2.kidsdial.com:81/media/cases/apple.png'"
border="0" alt=""/>
  <ul>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4.html">Apple Iphone 4</a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 4s </a>
    </li>
	<li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4.html">Apple Iphone 4</a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 4s </a>
    </li>
  </ul>
</div>

<div class="grow">
  <img class = "expand" src="http://sbdev2.kidsdial.com:81/media/cases/apple.png" onmouSEOver="this.src='http://sbdev2.kidsdial.com:81/media/cases/apple_active.png'"
onmouSEOut="this.src='http://sbdev2.kidsdial.com:81/media/cases/apple.png'"
border="0" alt=""/>
  <ul>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4.html">Apple Iphone 1</a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 2 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 3 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 4 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 5 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 6 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 7 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 8 </a>
    </li>
	<li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 9 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 10 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 11 </a>
    </li>
    <li>
      <a class="links1234" href = "http://sbdev2.kidsdial.com:81/cases-covers/art-graphics/iphone-4s.html">Apple Iphone 12 </a>
    </li>
  </ul>
</div>

注意:我只需要在2列中显示,如果我们有超过7个值,如果我们悬停在第一个图像上,而不是只显示4个值,因为我不想在4列中显示

这个问题不重复,因为当我使用其他问题的答案时,它破坏了我的列宽….

解决方法

使用下面的CSS

.grow:hover ul{
  display: block;
  column-count: 2;
}
.grow:hover ul li{
    display: inline-table;
    padding: 5px 12px;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐