How to have images in line with text in css

前端 未结 6 1601
时光说笑
时光说笑 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 03:37

    I find a lot of the time I need to adjust the position of the image to align with the text. You can do this by wrapping the text and image in a div with position relative and then assigning position absolute on the image. Then you ca add top and margin left to adjust the position relative to the text. https://jsfiddle.net/edhescqn/3/

    HTML:

    
    

    CSS:

    .amazonLink {
      position: relative;
      margin-top: 10px;
    }
    
    .amazonLink__text {
      display: inline-block;
      line-height: 40px;
    }
    
    .amazonLink__image {
      display: inline-block;
      position: absolute;
      top: 8px;
      margin-left: 5px;
    }
    

提交回复
热议问题