cuốn sách gpt4 ai đã làm

jquery - CSS height 和 inline height 属性不服从我

In lại Tác giả: Walker 123 更新时间:2023-11-28 17:26:38 29 4
mua khóa gpt4 Nike

我对容器 div 的高度有疑问。我想 它是 body 的 100%,但不起作用。我添加了 css body height=100%

var d = document;
$(d).ready(function () {
$("#con").append($("
").css({
'height':' 50px',
'width': '100px',
'background': 'lightgreen',
'borderRadius':'5px',
'position':'absolute',
'left':'100px',
'top' :'100px'

})).on("mousemove",function(e){
var x = e.pageX-$("#con").offset().left;
var y = e.pageY-$("#con").offset().top;
$("#d").html(x+" "+y);
});

});
/*edit*/ 
body ,html {
lề:0;
height:100%;}
/*endof edit*/
#con{
đường viền:1px màu đen đặc;
chiều rộng: 100%;
height:100%;/*not working as expected*/
}


câu trả lời hay nhất

为了使高度的 % 值有效,您需要一个引用值,父级的固定值 ... 为 html 和 body 设置 100%标签也是:

html, nội dung {
lề:0;
chiều cao:100%;
}

var d = document;
$(d).ready(function () {
$("#con").append($("
").css({
'height':' 50px',
'width': '100px',
'background': 'lightgreen',
'borderRadius':'5px',
'position':'absolute',
'left':'100px',
'top' :'100px'

})).on("mousemove",function(e){
var x = e.pageX-$("#con").offset().left;
var y = e.pageY-$("#con").offset().top;
$("#d").html(x+" "+y);
});

});
html, nội dung {
lề:0;
chiều cao:100%;
}
#con{
background:black;
chiều rộng: 100%;
height:100%;/*not working as expected*/
}


关于jquery - CSS height 和 inline height 属性不服从我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27070505/

29 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress