-1

嗨,我正在使用以下 css 创建自定义按钮

    .myBlackButton02 {
    -moz-box-shadow:inset 0px -3px 7px 0px #6a6f76;
    -webkit-box-shadow:inset 0px -3px 7px 0px #6a6f76;
    box-shadow:inset 0px -3px 7px 0px #6a6f76;
    background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #61656c), color-stop(1, #292b2e));
    background:-moz-linear-gradient(top, #61656c 5%, #292b2e 100%);
    background:-webkit-linear-gradient(top, #61656c 5%, #292b2e 100%);
    background:-o-linear-gradient(top, #61656c 5%, #292b2e 100%);
    background:-ms-linear-gradient(top, #61656c 5%, #292b2e 100%);
    background:linear-gradient(to bottom, #61656c 5%, #292b2e 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#61656c', endColorstr='#292b2e',GradientType=0);
    background-color:#61656c;
    -moz-border-radius:3px;
    -webkit-border-radius:3px;
    border-radius:3px;
    border:1px solid #040405;
    display:inline-block;
    cursor:pointer;
    color:#ffffff;
    font-family:Tahoma;
    padding:9px 23px;
    text-decoration:none;
    text-shadow:0px 1px 0px #263666;
}
.myBlackButton02:hover {
    background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #292b2e), color-stop(1, #61656c));
    background:-moz-linear-gradient(top, #292b2e 5%, #61656c 100%);
    background:-webkit-linear-gradient(top, #292b2e 5%, #61656c 100%);
    background:-o-linear-gradient(top, #292b2e 5%, #61656c 100%);
    background:-ms-linear-gradient(top, #292b2e 5%, #61656c 100%);
    background:linear-gradient(to bottom, #292b2e 5%, #61656c 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#292b2e', endColorstr='#61656c',GradientType=0);
    background-color:#292b2e;
}
.myBlackButton02:active {
    background:transparent;
}

我正在使用的html是

<div id="d1" style="height:46px;top:0px;left:0px;right:0px;" class="heading01" >
        <div id="d2" class="style1" style="position:absolute;left:10px;top:4.5px;color:#FFF;">Heading</div>

        <div align="right" style="padding-top:2.5px;padding-right:10px;">

            <button class="myBlackButton02" style="font-size:10pt;outline:none;"> x </button>
            <button class="myBlackButton02" style="font-size:10pt;outline:none;"> x </button>


            <button class="myBlackButton02" style="font-size:10pt;outline:none;">
                <img src="icons/extensions/right_16.png" style=""/> 
            </button>
</div>

标题01的CSS是

.heading01{
    background: rgb(69,72,77); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(69,72,77,1) 0%, rgba(0,0,0,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(69,72,77,1)), color-stop(100%,rgba(0,0,0,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(69,72,77,1) 0%,rgba(0,0,0,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(69,72,77,1) 0%,rgba(0,0,0,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(69,72,77,1) 0%,rgba(0,0,0,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(69,72,77,1) 0%,rgba(0,0,0,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
}

我得到的是

在此处输入图像描述

但我想要的是所有按钮都处于相同的垂直高度。我知道有办法做到这一点,但我不知道怎么做。所以任何帮助将不胜感激。我什至尝试通过将图像设置为背景图像但渐变变为纯色,甚至尝试使用 div 但它与图像相同。谢谢

4

3 回答 3

1

您在 html 末尾缺少一个结束 div 标记。此外,删除填充并为按钮设置宽度和高度。如前所述,将垂直对齐设置为中间。 看这里

简化的 CSS:

.myBlackButton02 {
    /*padding:9px 23px;*/
    width: 80px;
    height: 80px;
    vertical-align: middle;
    margin-right: 10px;
}
于 2014-06-08T22:01:09.313 回答
0

在你的 CSS 中设置一个 margin-top: x px; 对于每一个,这应该使他们都水平。祝你好运

于 2014-06-08T21:32:16.140 回答
0

您应该将下一个代码添加到您的 .myBlackButton02 CSS:

vertical-align: middle;
width: 50pt;
height: 30pt;

您必须根据图像定义首选按钮的宽度和高度。

于 2014-06-08T21:38:36.013 回答