How to have images in line with text in css

前端 未结 6 1609
时光说笑
时光说笑 2021-01-02 03:06

I\'m creating the footer of my website using html and css.

I want to have the two facebook and twitter images in line with the text so that everything in the footer

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-02 04:02

    tags are block-level elements. Use an inline element such as :

    
    

    Alternatively, if you're able to use CSS, you can define both elements as inline-block:

    .footer.content > img,
    .footer.content > p {
        display: inline-block;
    }
    

    Example 1 jsFiddle

    Example 2 jsFiddle

    EDIT: It might also be wise for semantics to use

    , rather than . For example:

    
    

    Since

    is also a block-level element, you'll need to include the correct CSS as follows:

    .footer.content > img,
    .footer.content > address {
        display: inline-block;
    }
    

    Final jsFiddle example

提交回复
热议问题