div css 高度调整
我的网站中有以下 div:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.popup
{
float: left;
position: fixed;
top: 50%;
left: 50%;
margin-left: -332px;
margin-top: -260px;
width: 665px;
height: 550px;
border: solid 1px blue;
z-index: 100;
}
</style>
</head>
<body>
<div class="popup" >content content content...</div>
body body body.....
<br />
</html>
和此 css
.popup
{
float:left;
position: fixed;
top: 50%;
left: 50%;
margin-left: -332px;
margin-top: -260px;
width: 665px;
height:550px;
z-index:100;
}
我有一个问题,当屏幕分辨率低于 1024x768(即 800x600)时,div 未完全显示。弹出窗口的顶部和底部被剪掉。
我正在寻找 css 代码或 js 来检测分辨率低于 600(高度)的客户端,并将调整 div 高度并添加滚动条。 对于所有其他客户,我想将 div 高度保持为 550px;
i have the following div in my website:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.popup
{
float: left;
position: fixed;
top: 50%;
left: 50%;
margin-left: -332px;
margin-top: -260px;
width: 665px;
height: 550px;
border: solid 1px blue;
z-index: 100;
}
</style>
</head>
<body>
<div class="popup" >content content content...</div>
body body body.....
<br />
</html>
and this css
.popup
{
float:left;
position: fixed;
top: 50%;
left: 50%;
margin-left: -332px;
margin-top: -260px;
width: 665px;
height:550px;
z-index:100;
}
I have a problem that the div is not fully shown when screen resoultion is lower than 1024x768 (ie 800x600). the top and bottom part of the popup is clipped.
Im looking for a css code or js to detect client with resoultion lower than 600(height) and will resize the div height and add scrollbars.
for all other customers i want to keep the div height 550px;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您最好检测浏览器窗口客户区而不是屏幕分辨率。
You would be better off detecting browser window client area rather than screen resolution.
以下 JavaScript 代码可以帮助您获取屏幕的宽度和宽度。高度:
Following javascript code may help you to get the screen's width & height:
我认为最好的方法是使用 JavaScript 来做到这一点。
但如果你绝对想用 CSS 来编写它,你可以使用 @media 特定的 CSS 规则。
试试这个:
I think the best way is to do this with JavaScript.
But if you absolutely want to write it with CSS, you can use @media specific CSS rules.
Try this :