Set a Fixed div to 100% width of the parent container

前端 未结 7 1670
忘了有多久
忘了有多久 2020-12-09 00:52

I have a wrapper with some padding, I then have a floating relative div with a percentage width (40%).

Inside the floating relative div I have a fixed div which I w

7条回答
  •  一个人的身影
    2020-12-09 01:06

    How about this?

    $( document ).ready(function() {
        $('#fixed').width($('#wrap').width());
    });
    

    By using jquery you can set any kind of width :)

    EDIT: As stated by dream in the comments, using JQuery just for this effect is pointless and even counter productive. I made this example for people who use JQuery for other stuff on their pages and consider using it for this part also. I apologize for any inconvenience my answer caused.

提交回复
热议问题