gpt4 book ai didi

jquery - 在使用百分比时阻止 CSS 调整大小

转载 作者:太空宇宙 更新时间:2023-11-04 00:05:51 25 4
gpt4 key购买 nike

当我在 css 中使用百分比时,如何让我的页面不调整大小?我还有其他方法可以做到这一点吗?调整页面大小时,Divs 相互碰撞并且图片被压扁。这是我的代码:

<!DOCTYPE html>
<html>
<head>
<link rel="StyleSheet" href="StyleSheets/StyleSheet.css" />
<title>TeraShare</title>
<script type="text/javascript" src="JQuery/JQuery.js"></script>
<script type="text/javascript" src="Scripts/JavaScript.js"></script>
</head>
<body>
<div id="Container">
<div id="Menu">
<div id="Logo"><a href=""><img src="Pictures/Logo.png"></a></div>
<div id="Buttons">
<a href="LogIn/"><div class="Button">LogIn</div></a>
<a href="Register/"><div class="Button">Register</div></a>
</div>
</div>
<div id="Wrap">
<div id="Content">
<div id="Slide">
<div><img src="Pictures/Cloud1.jpg" class="Slide"></div>
<div><img src="Pictures/Cloud2.jpg" class="Slide"></div>
<div><img src="Pictures/Cloud3.jpg" class="Slide"></div>
</div>
</div>
<div id="Footer">
<table>
<tr><td><h4 class="Text">Support</h4></td><td class="TD"><h4 class="Text">Legal</h4></td></tr>
<tr><td><a href="Contact.php" class="Link">Contact Us</a></td><td class="TD"><a href="Terms.html" class="Link">Terms of Service</a></td></tr>
<tr><td></td><td class="TD"><a href="Privacy.html" class="Link">Privacy Policy</a></td></tr>
</table>
</div>
</div>
</div>
</body>

CSS:

    body
{
padding:0px;
margin:0px;
overflow-x:hidden;
word-wrap:break-word;
}

img
{
border:none;
}

#Menu
{
position:fixed;
top:0px;
left:0px;
width:100%;
height:49px;
border-bottom:rgba(82,82,82,1);
box-shadow:0 2px 3px rgba(182, 182, 182, 0.75);
background-color:rgb(68, 68, 68);
z-index:100;
}

#Container
{
padding:0px;
margin:0px;
}

#Content
{
width:100%;
height:auto;
background:url(../Pictures/Grid.gif);
}

#Footer
{
box-shadow: inset 0 20px 20px -20px #CCC;
box-sizing:border-box;
border-top:2px solid #666;
width:100%;
height:auto;
padding:20px;
}

#Wrap
{
position:absolute;
top:50px;
left:0px;
width:100%;
height:auto;
}

#Buttons
{
position:absolute;
right:20px;
}

#Logo
{
position:absolute;
top:0px;
left:20px;
}

.Slide
{
width:100%;
height:100%;
margin:0px;
padding:0px;
display:block;
}

.Button
{
margin-left:5px;
float:left;
line-height:20px;
padding:10px;
color:#FFF;
width:auto;
height:20px;
background-color:#347EBA;
font-family:arial;
font-size:14px;
}

.Button:hover
{
cursor:pointer;
background-color:#347EDA;
}

.Link
{
color:#666;
text-decoration:none;
font-size:13px;
font-family:Arial;
font-weight:bold;
}

.Link:hover
{
text-decoration:underline;
}

.Text
{
font-family:Arial;
font-weight:bold;
color:#333;
}

.TD
{
padding-left:30px;
padding-bottom:5px;
}

JQuery:

    $(document).ready(function()
{
var Height = $(document).height();
var Width = $(document).width();
var BHeight = $('#Buttons').height();

$('#Container').css({"height" : Height, "width" : Width});
$('#MWrap').css({"left" : Width/2 - 956/2});
$('#Buttons').css({"top" : 50/2 - BHeight/2});
$('#Content').css({"height" : Height - 50});


$("#Slide > div:gt(0)").hide();

setInterval(function() {
$('#Slide > div:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('#Slide');
}, 5000);
});

最佳答案

百分比是可变的。阻止它们调整大小的唯一方法是为相关元素或其父容器设置 min-widthmax-width 或特定像素值。

关于jquery - 在使用百分比时阻止 CSS 调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14904271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com