添加填充到文本但不添加图像

时间:2014-04-10 17:27:03

标签: html css alignment padding

我试图制作一个Tumblr主题,并试图让文字远离边框20px,但它也推动了照片,视频和其他非文字的元素,这是应该做的,是有没有办法只对齐文本?

        .posts {
            border:solid 1px #333333;
            border-radius:15px 15px 15px 15px;
            color:black;
            margin-bottom:20px;
            min-height:120px;
            padding-left:20px;
            text-align:left;
        }

这就是我的代码。

http://puu.sh/83iTL.jpg

这就是发生了什么,但我想只对齐文本。这可能吗?

谢谢:)

编辑:整个代码:http://pastebin.com/6q4hFyZL,页面为em202020.tumblr.com

2 个答案:

答案 0 :(得分:0)

<edit>

从您的信息页:http://em202020.tumblr.com/

你可以这样做:

.posts   a:first-of-type img,
.posts iframe {
margin-left:-80px;
}

或者如果你更喜欢它:

.posts   a:first-of-type img {
    margin-left:-80px;
    }
 .posts iframe {
margin-left:-20px;
    }

</edit>


首先猜测答案无关紧要。 你可以这样做:

.posts img:first-child {/* it will only select the first-child if it is an img tag */
margin-left:-20px;/* swallow that padding-left:20px; */
}

答案 1 :(得分:0)

你能为.post img添加css规则吗?

        .posts {
        border:solid 1px #333333;
        border-radius:15px 15px 15px 15px;
        color:black;
        margin-bottom:20px;
        min-height:120px;
        padding-left:20px;
        text-align:left;
    }


       #add this?#
       .posts img {
       padding:0px;