css - 鼠标悬停在列表项上晃动

标签 css positioning margin padding

当我将鼠标悬停在 here 上的列表项上时,如何防止晃动?到目前为止,我已经尝试过不同的边距和填充。我还检查了哪个 css 元素溢出,但找不到任何结果。

我的CSS在这里:

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
    background:#000000;
    color:#fff;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}


.temizle{clear:both;}

#containerANA{
    width:1100px;
    height:auto;
    margin: 0 auto;
    font:10px arial, helvetica, Geneva, sans-serif;

}


#content{
    width:100%;
    margin-top:0px;
}


#content p{
  position: relative;
  margin-left:auto;
  margin-right:auto;
  top:0px;
  display: block;
  padding: 5px;    
  color: #769B4E;
  font-size:18px;
  font-family: arial, helvetica, Geneva, sans-serif;
  text-align:justify;   
  border: 0px solid #769B4E;
  margin-top: 10px;
  margin-bottom: 10px;
}

#content p a{
    color:#ccc;
    text-decoration:none;
}

#content p a:hover{
    background:#e5da5f;
    color:#000;
}



.ikinciSol{
    width:550px;
    height:auto;
    float:left;
    margin-right:0px;
    font-family:Verdana, Geneva, sans-serif;
    text-align:left;
}

.ikinciSol h1{
    font-weight:bold;
    text-decoration:none;
    font-size:14px;
    font-family:Verdana, Geneva, sans-serif;
    color:#fb891a;
}

.ikinciSol ul
{
    list-style-type: none;

}

.ikinciSol #playlist li {
    margin-left:50px;
}

.ikinciSol ul li .singer{
    font-size:18px;
    display:inline;
}

.ikinciSol ul li .song{
    font-size:14px;
    display:inline;
}

.ikinciSol ul li a{
    text-decoration:none;
    color:#fff;
    margin-right:5px;

}

.ikinciSol ul li .singer a:hover{
    background:#e5da5f;
    color:#000;
}

.ikinciSol ul li  .song a:hover{
    background:#FF9966;
    color:#000;
}

.artist_track{
    margin-right:12px;

}
.fav{

}    



.ilgiliOge{
    width:402px;
    height:306px;
    font-size:24px;
    padding:0px;
}

最佳答案

问题是,当您将鼠标悬停时, <li> 的高度由于共享按钮而发生变化。为了防止这种情况发生,您应该给出 min-height到列表项。最重要的是,如果您想让文本相对于按钮居中,您还应该给它一个 line-height以及更多调整。

CSS 代码:

.ikinciSol #playlist li {
    min-height:40px;
    line-height:40px;
}
.ikinciSol #playlist li .fav a {
    position:relative;
    top:5px;
}

JSFiddle 链接:http://jsfiddle.net/vZnFF/

PS:您不应在列表项之间添加分隔符。 PS2:您可以仅使用 CSS 实现相同的 :hover 效果。

关于css - 鼠标悬停在列表项上晃动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13982023/

相关文章:

html - Webkit 浏览器中的意外边距

javascript - 使用 javascript 滚动时如何保持类事件?

CSS - 无法覆盖 WordPress 的 'Continue Reading' 文本的样式

css:绝对位置不利于右值和底值?

css - Bootstrap 中奇怪的 CSS 效果。在容器 div 中显示大量内容 div 时意外缩进

css - 自动页边距不会使页面中的图像居中

html - 单击 css float 选择字段标题

javascript - Div 位置不适用于任何值设置

css - 如何创建网格/平铺 View ?

HTML 图像未在电子邮件中定位