gpt4 book ai didi

html - 为什么我的部分没有正确地靠右?

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

我目前正在制作一个网页,其中有一个侧面部分,例如这张照片中的那个:

enter image description here

我目前拥有的是:

enter image description here

为什么我的侧栏没有像第一张图片中那样显示?我试图制作侧栏并通过放置“侧栏????”来测试它的位置,但是它没有正确显示。我的代码如下:

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>int222_162d16 - Assignment 2 - Home Page</title>
<link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/sitecss.css" type="text/css" media="screen" />
</head>
<body>
<nav class="fixed-nav-bar">
<ul class="nav">
<li class="nav"><a href="../index.html">&spades; My Zenit Account</a></li>
<li class="nav"><a class="active" href="index.html">Home</a></li>
<li class="nav"><a href="gallery.html">Gallery</a></li>
<li class="nav"><a href="video.html">Video</a></li>
<li class="nav"><a href="audio.html">Audio</a></li>
<li class="nav"><a href="table.html">Tables With CSS</a></li>
<li class="nav"><a href="pizza/index.html">Forms</a></li>
<li class="nav"><a href="css/sitecss.css">CSS Used</a></li>
<li class="nav"><a href="extra/index.html">Extra</a></li>
</ul>
</nav>
<h1>Welcome To The Home Page!</h1>



<div class="s">
<section class="s">
<h3>HTML5 & CSS Normalize</h3>
<p>The reason why we use normalize.css is due to it providing cross-browser consistency in the styling of HTML elements.</p>
<aside><p>SIDE COLUMN???</p></aside>
</section>

<aside><p>SIDE COLUMN???</p></aside>

<section class="s">
<h3>TEXT</h3>
<p>
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
</p>
</section>
</div>

<hr />
<footer>
<script>
var dt=new Date(document.lastModified); // Get document last modified date
document.write('<p>This page was last updated on '+dt.toLocaleString()) + '</p>';
</script>
</footer>
</body>
</html>

CSS:

/*nav.fixed-nav-bar
{
position: fixed;
top: 0;
left: 0;
z-index: 9999;
width: 100%;
height: 50px;
margin-top: 10px;
}
*/
ul.nav
{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #f3f3f3;
border: 1px solid #e7e7e7;
box-shadow: 5px 2px 10px #808080;
}

li.nav
{
float: left;
}

li a
{

display: block;
color: #666;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

/* Change the link color on hover*/

li a:hover:not(.active)
{
background-color: #ddd;
}

li a.active
{
color: #ffffff;
background-color: #9999ff;
}

section.s /*shadow on sections*/
{
background-color: #ccccff;
box-shadow: 5px 2px 10px #808080;
width:63%;


}

/*div.s
{
box-shadow: 5px 2px 10px #808080;


}
*/
footer
{

width:100%;
background:#ccccff;
color:#000000;
border:1px solid #cccccc;
position:absolute;
text-align:center;
font-weight:bold;
display:inline-block;
margin: 0px auto;
line-height:20px;
box-shadow: 5px 2px 10px #808080;
clear: both;
}
aside {
float: right;
width: 30%;
}

最佳答案

我会说,您需要将 HTML 更改为

<div class="s">
<aside>
<section class="s">
<p>SIDE COLUMN???</p>
</section>
</aside>

<section class="s">
<h3>HTML5 & CSS Normalize</h3>
<p>The reason why we use normalize.css is due to it providing cross-browser consistency in the styling of HTML elements.</p>
</section>


<section class="s">
<h3>TEXT</h3>
<p>
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
</p>
</section>
</div>

看,我搬了<aside>超出部分,使其向右浮动

关于html - 为什么我的部分没有正确地靠右?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38042636/

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