按钮后的CSS怪异破折号

时间:2015-04-09 16:08:07

标签: html css button

基本上我在网页设计中使用了这些按钮。但是我刚刚注意到在更改背景时他们在按钮后面有这个奇怪的短划线( - )。

CSS:

* {
    font-family: 'Caviar Dreams';
}
.button-fill {
    text-align: center;
    background: #ccc;
    display: inline-block;
    position: relative;
    text-transform: uppercase;
    margin: 25px;
    border:dashed 0px #000000;
    -moz-border-radius-topleft: 17px;
    -moz-border-radius-topright:17px;
    -moz-border-radius-bottomleft:17px;
    -moz-border-radius-bottomright:17px;
    -webkit-border-top-left-radius:17px;
    -webkit-border-top-right-radius:17px;
    -webkit-border-bottom-left-radius:17px;
    -webkit-border-bottom-right-radius:17px;
    border-top-left-radius:17px;
    border-top-right-radius:17px;
    border-bottom-left-radius:17px;
    border-bottom-right-radius:17px;
}

.button-fill.orange {
    background: #B26B24;
    color: #fff;
}
.button-fill.orange .button-inside {
    color: #f26b43;
}

.button-text {
    padding: 0 25px;
    line-height: 56px;
    letter-spacing: .1em;
}
.button-inside {
    width: 0px;
    height: 54px;
    margin: 0;
    float: left;
    position: absolute;
    top: 1px;
    left: 50%;
    line-height: 54px;
    color: #445561;
    background: #0033CC;
    text-align: center;
    overflow: hidden;
    -webkit-transition: width 0.5s, left 0.5s, margin 0.5s;
    -moz-transition: width 0.5s, left 0.5s, margin 0.5s;
    -o-transition: width 0.5s, left 0.5s, margin 0.5s;
    transition: width 0.5s, left 0.5s, margin 0.5s;
    -moz-border-radius-topleft: 75px;
    -moz-border-radius-topright:75px;
    -moz-border-radius-bottomleft:75px;
    -moz-border-radius-bottomright:75px;
    -webkit-border-top-left-radius:75px;
    -webkit-border-top-right-radius:75px;
    -webkit-border-bottom-left-radius:75px;
    -webkit-border-bottom-right-radius:75px;
    border-top-left-radius:75px;
    border-top-right-radius:75px;
    border-bottom-left-radius:75px;
    border-bottom-right-radius:75px;
}
.button-inside.full {
    width: 100%;
    left: 0%;
    top: 0;
    margin-right: -50px;
    border: 1px solid #445561;
}
.inside-text {
    text-align: center;
    position: absolute;
    right: 50%;
    letter-spacing: .1em;
    text-transform: uppercase;
    -webkit-transform: translateX(50%);
    -moz-transform: translateX(50%);
    -ms-transform: translateX(50%);
    transform: translateX(50%);
}

我认为以下代码是问题,它位于.button-fill。

display: inline-block;

我尝试删除它,更改它,但它会阻止按钮工作。我已经走到了尽头。有谁知道我会如何解决这个问题?或者需要重新设计按钮吗?

奇怪的破折号图片:

enter image description here

HTML代码:

<CENTER>
    <div class="mywork" id="portfolio">
        <a href="./forum/">
            <div class="button-fill orange">
                <div class="button-text">Outside text</div>
                <div class="button-inside">
                    <div class="inside-text">inside&nbsptext </div>
                </div>
            </div>
        </a>
        <a href="#">
            <div class="button-fill orange">
                <div class="button-text">Outside text</div>
                <div class="button-inside">
                    <div class="inside-text">Inside&nbspText </div>
                </div>
            </div>
        </a> 
    </div> 
</CENTER>

2 个答案:

答案 0 :(得分:1)

短划线归因于<a>默认样式。

您可以将属性text-decoration: none;添加到a选择器。

答案 1 :(得分:0)

内联元素对空白区域很敏感,因此一个简单的方法就是删除锚点和div之间的空格(不需要更改CSS)。另外,请勿使用已弃用的<center>元素,并且不间断的空间实体为&nbsp;

* {
    font-family:'Caviar Dreams';
}
.button-fill {
    text-align: center;
    background: #ccc;
    display: inline-block;
    position: relative;
    text-transform: uppercase;
    margin: 25px;
    border:dashed 0px #000000;
    -moz-border-radius-topleft: 17px;
    -moz-border-radius-topright:17px;
    -moz-border-radius-bottomleft:17px;
    -moz-border-radius-bottomright:17px;
    -webkit-border-top-left-radius:17px;
    -webkit-border-top-right-radius:17px;
    -webkit-border-bottom-left-radius:17px;
    -webkit-border-bottom-right-radius:17px;
    border-top-left-radius:17px;
    border-top-right-radius:17px;
    border-bottom-left-radius:17px;
    border-bottom-right-radius:17px;
}
.button-fill.orange {
    background: #B26B24;
    color: #fff;
}
.button-fill.orange .button-inside {
    color: #f26b43;
}
.button-text {
    padding: 0 25px;
    line-height: 56px;
    letter-spacing: .1em;
}
.button-inside {
    width: 0px;
    height: 54px;
    margin: 0;
    float: left;
    position: absolute;
    top: 1px;
    left: 50%;
    line-height: 54px;
    color: #445561;
    background: #0033CC;
    text-align: center;
    overflow: hidden;
    -webkit-transition: width 0.5s, left 0.5s, margin 0.5s;
    -moz-transition: width 0.5s, left 0.5s, margin 0.5s;
    -o-transition: width 0.5s, left 0.5s, margin 0.5s;
    transition: width 0.5s, left 0.5s, margin 0.5s;
    -moz-border-radius-topleft: 75px;
    -moz-border-radius-topright:75px;
    -moz-border-radius-bottomleft:75px;
    -moz-border-radius-bottomright:75px;
    -webkit-border-top-left-radius:75px;
    -webkit-border-top-right-radius:75px;
    -webkit-border-bottom-left-radius:75px;
    -webkit-border-bottom-right-radius:75px;
    border-top-left-radius:75px;
    border-top-right-radius:75px;
    border-bottom-left-radius:75px;
    border-bottom-right-radius:75px;
}
.button-inside.full {
    width: 100%;
    left: 0%;
    top: 0;
    margin-right: -50px;
    border: 1px solid #445561;
}
.inside-text {
    text-align: center;
    position: absolute;
    right: 50%;
    letter-spacing: .1em;
    text-transform: uppercase;
    -webkit-transform: translateX(50%);
    -moz-transform: translateX(50%);
    -ms-transform: translateX(50%);
    transform: translateX(50%);
}
<CENTER>
    <div class="mywork" id="portfolio"> <a href="./forum/">
            <div class="button-fill orange">
                <div class="button-text">Outside text</div>
                <div class="button-inside">
                    <div class="inside-text">inside&nbsp; </div>
                </div>
            </div></a>
 <a href="#"><div class="button-fill orange">
                <div class="button-text">Outside text</div>
                <div class="button-inside">
                    <div class="inside-text">Inside&nbsp; </div>
                </div>
            </div>
        </a> 
    </div>
</CENTER>