html - 热制作 li :hover Not Move Siblings

标签 html css

我试图在悬停时放大我的列表项边框,但当我这样做时,它会将其他图标向下移动。

我的想法是在父级上使用 position: absolute ,在 li 或图像上使用 position: relative ,但其他列表项/图像仍然受到影响.

jsFiddle: http://jsfiddle.net/2e07Lv9y/2/

HTML:

<div class="container">
    <ul class="social">
        <li><img src="http://placehold.it/36x36"/></li>
        <li><img src="http://placehold.it/36x36"/></li>
        <li><img src="http://placehold.it/36x36"/></li>
        <li><img src="http://placehold.it/36x36"/></li>
        <li><img src="http://placehold.it/36x36"/></li>
    </ul>
</div>

CSS:

.container {
    background-color: rgb(54, 129, 245);
    height: 75px;
}

.social {
    width: 50%;
    margin: 3%;
    position: absolute;
    right: 0;
}

li {
    list-style: none;
    display: inline-block;
    margin: 0 1%;
}

img {
    border: 2px white solid;
}

li:hover {
    cursor: pointer;
    border: 5px white solid;
    position: relative;
}

我错过了什么?

最佳答案

您可以使用outline 而不是border。 Outlinke 的行为类似于 border,但它不是元素尺寸的一部分。 参见:http://www.w3schools.com/css/css_outline.asp

li:hover {
    cursor: pointer;
    outline: 5px white solid;
    position: relative;
}

fiddle :http://jsfiddle.net/2e07Lv9y/7/

关于html - 热制作 li :hover Not Move Siblings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28839902/

相关文章:

JavaScript 在输出中添加引号

javascript - [Vue警告] : Property or method "first" and "last" is not defined

html - css - 显示 : table-cell and fixed width

html - 如何修复水平菜单的垂直对齐方式?

html - 如何在 bootstrap 4 中订购 div?

css - 在Jinjia2中,如何在html样式中使用变量值?

javascript - 从另一个选项卡获取拖放图像作为 base64String

javascript - 使用提交按钮保存响应 (html)

javascript - 在 Bootstrap 中向下滚动时菜单消失

html - 如何适应屏幕全高(使用CSS)?