CSS溢出:隐藏剪切阴影

时间:2015-11-27 01:06:21

标签: css css3 twitter-bootstrap-3

这就是现在的样子:

enter image description here

当我禁用overflow: hidden;时,阴影通常都在周围,但是当它开启时 - 它会在左侧和顶部剪切。我不确定为什么它只削减这两个方面,但现在看起来仍然不好看。如何摆脱它?

代码:

.toolong {
        width: 80%;
        overflow: hidden; 
        white-space:nowrap; 
        text-overflow: ellipsis;
    }
.shadow {
  text-shadow: 2px 2px 2px black, -2px -2px 2px black, 2px -2px 2px black, -2px 2px 2px black, 4px 4px 4px black, -4px -4px 4px black, 4px -4px 4px black, -4px 4px 4px black;
  font-weight: bold;
}

<div class="col-sm-12">
                <h2 class="pull-right"><span class="label label-warning">1</span></h2>
            <h3 class="pull-left shadow toolong">         
               Piotrek z Bagien
               <br>
               <span><h4 class="gray shadow">Pinta</h4></span>
                <span><h6 class="gray shadow">India Pale Ale (Poland)</h6></span>              
            </h3>   
            </div>

1 个答案:

答案 0 :(得分:10)

我建议在顶部和左侧添加padding

JS Fiddle

.toolong {
    width: 80%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-left: 5px;
    padding-top: 5px;
}

如果需要,可以使用负边距将它们重新对齐到位:

JS Fiddle

.toolong {
    width: 80%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-left: 5px;
    padding-top: 5px;
    margin-left: -5px;
    margin-top: -5px;
}