Image周围的空白

时间:2012-11-02 05:59:46

标签: css

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

enter image description here

标记:

       <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;}

2 个答案:

答案 0 :(得分:0)

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

#btnExpandSection {
    background: #ffffff url('/Content/Images/plus.jpg') no-repeat center center;
    height: /* image height */;
    width: /* image width */;
}

答案 1 :(得分: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; 
}
相关问题