using position:absolute to set an inputs width

后端 未结 4 460
没有蜡笔的小新
没有蜡笔的小新 2021-01-11 12:21

A simple yet annoying one - I am tryign to set an input[type=text] width by using absolute positioning (ie right:10px;left:10px) yet I cant get it to play ball.

Does

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-11 12:30

    As Marco said, you simply cannot do it that way. If you don't know the width of the page, you'd have to use javascript to achieve that effect:

    $('#myInput').css({ right: 10, position: 'absolute', width: $(document).width() - 20 })
    

提交回复
热议问题