gpt4 book ai didi

html - body 元素走出 body

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

body {
margin: 0px;
border: 1px solid black;
}

#head {
text-align: center;
background: linear-gradient(to right, cyan, purple);
margin: 0px;
padding: 20px;
border: 1px solid black;
}

#head h1 {
margin: 0px;
font-family: 'Great Vibes', cursive;
color: white;
font-size: 40px;
}

.contianer {
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
}

.ops {
display: flex;
justify-content: center;
border-bottom: 1px solid black;
border-top: 1px solid black;
}

#list ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}

#list li {
float: left;
padding: 0px;
margin: 0px;
}

#list li:hover {
background-color: lightgrey;
}

#list {
display: flex;
justify-content: center;
margin: 10px;
}

form {
padding: 0px;
margin: 0px;
}

.dhund {
display: flex;
justify-content: center;
padding: 10px;
}

input[name="name"] {
max-height: 37px;
max-width: 400px;
min-width: 200px;
border-radius: 10px;
font-size: 17px;
border: 1px solid black;
padding: 5px;
margin: 5px;
}

input[name="search"] {
background-color: rgb(183, 242, 184);
font-size: 15px;
border: 1px solid black;
border-radius: 5px;
color: black;
}

input[name="logout"],
input[name="chat"],
input[name="update"],
input[name="homepage"],
input[name="event"] {
background-color: white;
border: none;
padding: 10px 19px;
}

input[name="logout"]:hover,
input[name="chat"]:hover,
input[name="update"]:hover,
input[name="homepage"]:hover,
input[name="event"]:hover {
background-color: lightgrey;
}

.content {
display: flex;
flex-direction: row;
}

.sidebar {
display: flex;
flex-direction: column;
border-right: 1px solid black;
height: 100%
}

#image {
margin: 2px;
padding: 5px;
display: flex;
justify-content: center;
}

#image img {
border: 1px solid black;
}

#upload {
border-top: 1px solid black;
margin: 2px;
min-width: 250px;
}

#upload p {
text-align: center;
}

#stupid {
display: flex;
justify-content: center;
margin: 5px;
}

.material {
margin: 20px;
min-width: 400px;
border: 1px solid black;
border-radius: 10px;
background-color: lightgrey;
}

.posts {
border: 1px solid black;
margin: 17px;
margin-top: 80px;
border-radius: 7px;
}

.feed {
padding: 20px;
}

.post p {
padding: 5px;
}

.poster {
padding-left: 10px;
border-bottom: 1px solid black;
}

.poster p {}

#matter p {
text-indent: 30px;
}

#matter {
border: 1px solid black;
margin: 8px;
background-color: white;
border-radius: 20px;
padding: 20px;
}

.main {
display: flex;
flex-direction: column;
margin: 5px;
width: 100%;
}


/*#mind
{
display: flex;
flex-direction: row;
justify-content: center;
border: 1px solid black;
border-radius: 8px;
background-color: lightgrey;
}*/

textarea[name="mind"] {
border-radius: 10px;
border: 1px solid black;
font-size: 15px;
padding: 10px 5px 10px 5px;
}

input[name="post"] {
width: 120px;
height: 50px;
background-color: powderblue;
font-size: 17px;
}
<!DOCTYPE html>
<html>

<head>
<title>The Joint.</title>
<link rel="stylesheet" type="text/css" href="style1.css">
<link href="https://fonts.googleapis.com/css?family=Great+Vibes|Slabo+27px" rel="stylesheet">
</head>

<body>
<div id="head">
<h1>The Joint.</h1>
</div>

<div class="contianer">
<div class="ops">
<div id="list">
<ul>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="homepage" value="Homepage"></form>
</li>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="update" value="Update"></form>
</li>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="chat" value="Chat"></form>
</li>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="event" value="Your Events"></form>
</li>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="logout" value="logout"></form>
</li>
</ul>
</div>
</div>
<div class="dhund">
<form method="POST" action="homepage.php">
<input type="text" name="name" placeholder="Search for People or things">
<input type="submit" name="search" value="search">
</form>
</div>
<div class="content">

<div class="sidebar">
<div id="visual">
<div id="image">
<img src="<?php echo $avatar ?>" width="200" height="250">
</div>
<div id="upload">
<form action="homepage.php" method="POST" enctype="multipart/form-data">
<p>Upload Pic:</p><input type="file" name="img"><br>
<div id="stupid">
<input type="submit" name="upload" value="Upload">
</div>
</form>
</div>
</div>
</div>

<div class="main">
<div id="mind">
<form method="GET" action="homepage.php">
<textarea name="mind" cols="40" rows="5"></textarea>
<input type="submit" name="post" value="Post">
</form>
</div>
<div class="feed">
<div class="posts">
<div class="poster">
<p><b>Poster</b></p>
</div>
<div class="post">
<p>It give me immense pleasure To announce the arrival of happening to your college, Embrace..!</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>

</html>

我已经阅读了 <body> 中的所有内容标签将适合主体内部,主体将根据各个元素的宽度进行调整,但我设计的网站内容似乎超出了主体,我知道是因为我给主体一个边框,发现内容去当我调整浏览器大小时,在 body 外面。为什么首先会发生这种情况?制作全屏友好网站的最佳方法是什么?我也尝试使用 vw而不是 px这是个好主意吗?

最佳答案

一种方法是将正文变成内联 block 。
默认情况下,内联 block 与其内容的宽度相同,并且不受窗口宽度的限制。

body {
margin: 0px;
border: 1px solid black;
display: inline-block; /* new */
}

#head {
text-align: center;
background: linear-gradient(to right, cyan, purple);
margin: 0px;
padding: 20px;
border: 1px solid black;
}

#head h1 {
margin: 0px;
font-family: 'Great Vibes', cursive;
color: white;
font-size: 40px;
}

.contianer {
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
}

.ops {
display: flex;
justify-content: center;
border-bottom: 1px solid black;
border-top: 1px solid black;
}

#list ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}

#list li {
float: left;
padding: 0px;
margin: 0px;
}

#list li:hover {
background-color: lightgrey;
}

#list {
display: flex;
justify-content: center;
margin: 10px;
}

form {
padding: 0px;
margin: 0px;
}

.dhund {
display: flex;
justify-content: center;
padding: 10px;
}

input[name="name"] {
max-height: 37px;
max-width: 400px;
min-width: 200px;
border-radius: 10px;
font-size: 17px;
border: 1px solid black;
padding: 5px;
margin: 5px;
}

input[name="search"] {
background-color: rgb(183, 242, 184);
font-size: 15px;
border: 1px solid black;
border-radius: 5px;
color: black;
}

input[name="logout"],
input[name="chat"],
input[name="update"],
input[name="homepage"],
input[name="event"] {
background-color: white;
border: none;
padding: 10px 19px;
}

input[name="logout"]:hover,
input[name="chat"]:hover,
input[name="update"]:hover,
input[name="homepage"]:hover,
input[name="event"]:hover {
background-color: lightgrey;
}

.content {
display: flex;
flex-direction: row;
}

.sidebar {
display: flex;
flex-direction: column;
border-right: 1px solid black;
height: 100%
}

#image {
margin: 2px;
padding: 5px;
display: flex;
justify-content: center;
}

#image img {
border: 1px solid black;
}

#upload {
border-top: 1px solid black;
margin: 2px;
min-width: 250px;
}

#upload p {
text-align: center;
}

#stupid {
display: flex;
justify-content: center;
margin: 5px;
}

.material {
margin: 20px;
min-width: 400px;
border: 1px solid black;
border-radius: 10px;
background-color: lightgrey;
}

.posts {
border: 1px solid black;
margin: 17px;
margin-top: 80px;
border-radius: 7px;
}

.feed {
padding: 20px;
}

.post p {
padding: 5px;
}

.poster {
padding-left: 10px;
border-bottom: 1px solid black;
}

.poster p {}

#matter p {
text-indent: 30px;
}

#matter {
border: 1px solid black;
margin: 8px;
background-color: white;
border-radius: 20px;
padding: 20px;
}

.main {
display: flex;
flex-direction: column;
margin: 5px;
width: 100%;
}


/*#mind
{
display: flex;
flex-direction: row;
justify-content: center;
border: 1px solid black;
border-radius: 8px;
background-color: lightgrey;
}*/

textarea[name="mind"] {
border-radius: 10px;
border: 1px solid black;
font-size: 15px;
padding: 10px 5px 10px 5px;
}

input[name="post"] {
width: 120px;
height: 50px;
background-color: powderblue;
font-size: 17px;
}
<!DOCTYPE html>
<html>

<head>
<title>The Joint.</title>
<link rel="stylesheet" type="text/css" href="style1.css">
<link href="https://fonts.googleapis.com/css?family=Great+Vibes|Slabo+27px" rel="stylesheet">
</head>

<body>
<div id="head">
<h1>The Joint.</h1>
</div>

<div class="contianer">
<div class="ops">
<div id="list">
<ul>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="homepage" value="Homepage"></form>
</li>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="update" value="Update"></form>
</li>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="chat" value="Chat"></form>
</li>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="event" value="Your Events"></form>
</li>
<li>
<form action="homepage.php" method="GET"><input type="submit" name="logout" value="logout"></form>
</li>
</ul>
</div>
</div>
<div class="dhund">
<form method="POST" action="homepage.php">
<input type="text" name="name" placeholder="Search for People or things">
<input type="submit" name="search" value="search">
</form>
</div>
<div class="content">

<div class="sidebar">
<div id="visual">
<div id="image">
<img src="<?php echo $avatar ?>" width="200" height="250">
</div>
<div id="upload">
<form action="homepage.php" method="POST" enctype="multipart/form-data">
<p>Upload Pic:</p><input type="file" name="img"><br>
<div id="stupid">
<input type="submit" name="upload" value="Upload">
</div>
</form>
</div>
</div>
</div>

<div class="main">
<div id="mind">
<form method="GET" action="homepage.php">
<textarea name="mind" cols="40" rows="5"></textarea>
<input type="submit" name="post" value="Post">
</form>
</div>
<div class="feed">
<div class="posts">
<div class="poster">
<p><b>Poster</b></p>
</div>
<div class="post">
<p>It give me immense pleasure To announce the arrival of happening to your college, Embrace..!</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>

</html>

此解决方案确实使正文在宽屏幕上比窗口窄,但您可以通过添加 min-width 来解决这个问题。

关于html - body 元素走出 body ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53369521/

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