English 中文(简体)
J RequestRY: Resize div todow width
原标题:JQUERY: Resize div to window width
  • 时间:2011-11-11 14:43:14
  •  标签:
  • jquery

我正试图强行把一块小块 d到一个浏览器窗户的宽度。 因此,即使窗户正在转售,也会产生宽度。

我一直在研究大约一个小时,发现奇比特和碎块,例如,可找到任何可行的东西。

最佳回答

Without a container limiting the width, a div should span the width of the browser window by default. You can explicitly set the width to 100%, but that shouldn t be necessary:

<div style="width:100%;">Hello world</div>

我认为,特别安全局在此更为合适,但你可以这样做。

$("#div1").width($(window).width());

如果窗户重新布局,你可以这样做:

$(window).resize(function(){
    $("#div1").width($(window).width());
});

http://jsfiddle.net/MtUWn/“jsFiddle。 为了示范,四分五点在纽特州点击。

问题回答

为此:

<div id="full"></div>

<script type="text/javascript">
    function reSize($target){
        $target.css( width , $(window).width()+ px );
    }
    $(document).ready(function(){
        $(window).bind( resize , reSize($( #full )));
        $(window).trigger( resize );
    });
</script>

我希望这一帮助!

width: 100%;
display: block;

选择:

position: absolute;

我认为,你能够用100%的宽度来解决这一问题。

 div#full{ width:100%}

:





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签