Right-align block elements in HTML

后端 未结 8 862
故里飘歌
故里飘歌 2021-02-06 23:53

I\'d like to right-align block elements in a floating container.

Assume the following markup.

8条回答
  •  感情败类
    2021-02-07 00:44

    Put them in a div aligned right:

    Then use js to set the width of the div to the image:

    $('.container').width($('.image1').width());
    

    CSS:

    .image1 {
        width: 50px;
    }
    .image2 {
        width: 30px;
    }
    

    Though it is better with js it is not necessary for it to work

    Fiddle: http://jsfiddle.net/GuTZ3/2/

提交回复
热议问题