浮右的标题项=浮左怎么样?

时间:2015-05-29 09:41:28

标签: html css header

我有三个社交媒体按钮,浮动右,所有按钮都有不同的宽度。标题右侧还有一个h1,浮动右侧。但我向右浮动的社交媒体按钮不是向右浮动,而是在标题的左侧。

/*nieuwsbrief*/
#zoekveldandsocial > h1{
color: white;
float: right;
background-color: #e8b215;
font-size: 12px;
height: 15px;
padding: 13px;
text-align: center;
width: 100px;


}

/*facebook*/
#social > img:first-of-type{
width: 2%;
}

/*twitter*/
#social >img:nth-of-type(2){

width: 2%;
}

/*linkedin*/
#social > img:nth-of-type(3){

width: 2.1%;
}


#social{
float: right;

}


<div id="zoekveldandsocial">
<h1>Nieuwsbrief</h1>
<div id="social">
<img src="img/facebook.png" alt="facebook" />
<img src="img/twitter.png" alt="twitter" />
<img src="img/linkedin.png" alt="linkedin" />
</div>

https://jsfiddle.net/27zs3nhn/

3 个答案:

答案 0 :(得分:0)

尝试这需要将浮动权改为h1的左侧浮动。 https://jsfiddle.net/27zs3nhn/

  color: white;
    float: left;
    background-color: #e8b215;
    font-size: 12px;
    height: 15px;
    padding: 13px;
    text-align: center;
    width: 100px;


    }

    /*facebook*/
    #social > img:first-of-type{
    width: 2%;
    }

    /*twitter*/
    #social >img:nth-of-type(2){

    width: 2%;
    }

    /*linkedin*/
    #social > img:nth-of-type(3){

    width: 2.1%;
    }


    #social{
    float: right;

    }


    <div id="zoekveldandsocial">
    <h1>Nieuwsbrief</h1>
    <div id="social">
    <img src="img/facebook.png" alt="facebook" />
    <img src="img/twitter.png" alt="twitter" />
    <img src="img/linkedin.png" alt="linkedin" />
    </div>

答案 1 :(得分:0)

您的代码必须更改为此

/*nieuwsbrief*/
#zoekveldandsocial > h1{
color: white;
float: right;
background-color: #e8b215;
font-size: 12px;
height: 15px;
padding: 13px;
text-align: center;
width: 100px;


}

/*facebook*/
#social > img:first-of-type{
float: right;
width: 2%;

}

/*twitter*/
#social >img:nth-of-type(2){
float: right;
width: 2%;
}

/*linkedin*/
#social > img:nth-of-type(3){
float: right;
width: 2.1%;
}


<div id="zoekveldandsocial">
<h1>Nieuwsbrief</h1>
<div id="social">
<img src="img/facebook.png" alt="facebook" />
<img src="img/twitter.png" alt="twitter" />
<img src="img/linkedin.png" alt="linkedin" />
</div>

 然后它会告诉你你想要什么..

答案 2 :(得分:0)

CSS文件:

/*nieuwsbrief*/

#zoekveldandsocial > h1 { 
    color: white;
    float: right;
    background-color: #e8b215;
    font-size: 12px;
    height: 15px;
    padding: 13px;
    text-align: center;
    width: 100px;
}

/*facebook*/
#social > img:first-of-type{
    width: 2%;
}
/*twitter*/
#social >img:nth-of-type(2){
    width: 2%;
}

/*linkedin*/
#social > img:nth-of-type(3){
    width: 2.1%;
}

#social{
    float: left;
}
.socialnetwork{
    display:inline;
    margin:10px;
    text-decoration:none;
    padding: 10px; 
}

HTML文件:

<div id="zoekveldandsocial">
    <h1>Nieuwsbrief</h1>
    <div id="social">
        <a href="#" class="socialnetwork"><img src="img/facebook.png" alt="facebook" /></a>
        <a href="#" class="socialnetwork"><img src="img/twitter.png" alt="twitter" /></a>
        <a href="#" class="socialnetwork"><img src="img/linkedin.png" alt="linkedin" /></a>
    </div>

我跳这是你想要的,你可以通过改变保证金的价值来改变社交网络之间的差距。