1

无法弄清楚我是如何在图像周围获得额外的空白:

在此处输入图像描述

标记:

       <div id="member-name"  hidden="true">
            <button type="submit" id="btnExpandSection"><img src="~/Content/Images/plus.jpg" /></button><p id="member-fullName"></p> 
        </div>

样式:

   input, textarea 
    {
        border: 1px solid #e2e2e2;
        background: #fff;
        color: #333;
        font-size: .9em;
        margin: 5px 0 6px 0;
        padding: 5px 2px 5px 5px;
        width: 300px;
    }

    img 
    {
        display: block; /* gets rid off any unexpected margins round the image */
        border: 0px;
    }


    input[type="submit"], input[type="button"], button 
    {
            background-color: #ffffff;
            cursor: pointer;
            font-size: 11px;
            font-weight: 600;
            width: auto;
            vertical-align: middle;
        border: 0px;
    }

    td input[type="submit"], td input[type="button"], td button { font-size: 1em; }

更新:

里面也有这种风格:

#member-name 
{
    margin: 30px 0px 0px 0px;
    height: 30px;
    font-weight: bold;
    color: white;
    padding: 1px 1px 0px 1px;
    background-color: #d28105;
    border: 1px solid darkgray;
}


#member-fullName { margin: 0px 0px 0px 20px;}
#member-fullName p{ display: inline;float: left;overflow: hidden;}
4

2 回答 2

1

您不能只提供图像作为按钮元素的背景吗?

#btnExpandSection {
    background: #ffffff url('/Content/Images/plus.jpg') no-repeat center center;
    height: /* image height */;
    width: /* image width */;
}
于 2012-11-02T06:06:04.760 回答
0

我将从这个开始,然后从这里重新构建它......

button,
#member-fullName,
#member-name,
#btnExpandSection,
#btnExpandSection img {
    margin: 0;
    padding: 0;
}

但是下面肯定会最好是嵌套在<button></button>标签之间的图像。替换32px为图像的实际宽度和高度值。

button {
    background-image: url(~/Content/Images/plus.jpg);
    width: 32px;
    height: 32px; 
}
于 2012-11-02T06:33:04.603 回答