gpt4 book ai didi

html - Logo 不会在标题标签内向左或向右移动

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

我试图将我的 Logo 放在中心或我的页面(标题中心和菜单导航上方)它离开菜单但不会向左或向右横向移动,无论如何都保持在同一位置.

我已经尝试了所有搜索谷歌但没有结果显示。尝试使标题相对并尝试使菜单相对。这是我的代码。

body {
width: 800px;
margin: 100px auto 0 auto;
background: darkgrey;
font-family: arial;
display: block;
}

#header {
width: 800;
height: auto;
margin: 0;
background: transparent;
}

#h1.logo {
position: absolute;
right: 50px;
}

#tabs{
overflow: hidden;
width: 100%;
margin: 0;
padding: 0;
list-style: none;
}

#content
{
background: #fff;
padding: 2em;
height: 520px;
position: relative;
z-index: 2;
border-radius: 0 5px 5px 5px;
box-shadow: 0 -2px 3px -2px rgba(0, 0, 0, .5);
}

#tab2 {
position: relative;
}

#icons img {
padding-right:5px;
0% { /* space between content and footer*/
position: absolute;
top: 20;
right: 50px;
}

}
footer {
display: inline-block;
width:800px;
text-align: left;
margin-top: 250px;

}

footer ul {list-style-type: none;
text-align: center;
float: left;
}

footer li {display:inline;
}

footer a:link{
text-decoration: none;
}

footer p {
float:right;
}

table {border: solid darkgrey thin;
position: relative;
left: -100px;
z-index: 2;

<body>

<header>
<h1 class="logo">
<img src="images/Logodraft.png" alt="Kieron's Logo" title="Kieron's Logo" />
</h1>
</header>

<!--navigation starts here-->

<!--An unordered list that holds the tab navigation items-->
<ul id="tabs">
<li><a href="index.html" title="tab1">Home</a></li>
<li><a href="about.html" title="tab2">About</a></li>
<li><a href="portfolio.html" title="tab3">Portfolio</a></li>
<li><a href="blog.html" title="tab4">Blog</a></li>
</ul>

<!--A wrapper for each tab content-->

<div id="content">
</div>
<!--end content div-->

<footer> <!--footer starts here-->

<div id="tab3">

<table border="0" width=1024px height=0px>
<tr>
<td><a href="index.html"><img src="images/logoicon.png"/></a></td>
<td><a href="index.html">Home | </a> <a href="about.html">About | </a> <a href="portfolio.html">Portfolio | </a> <a href="blog.html">Blog</a></td>
<td align="right"><small>&copy;copyright 2016 Kieron Roberts</small></td>
</tr>
</table>

</div>


</footer> <!--end of footer-->

</body>

最佳答案

您可以通过将 text-align:center; 添加到图像的父级(带有类 Logo 的 h1)来解决此问题

我注意到你的页面右边有一个大嘴巴

首先:你不应该在 body 上使用宽度你必须创建一个容器并给它一个固定的宽度

第二:你不应该在你所有的页面中使用位置,那会把它弄乱,你应该只在需要的时候使用它

<header>
<h1 class="logo">
<img src="images/Logodraft.png" alt="Kieron's Logo" title="Kieron's Logo" />
</h1>
</header>

<!--navigation starts here-->

<!--An unordered list that holds the tab navigation items-->
<ul id="tabs">
<li><a href="index.html" title="tab1">Home</a></li>
<li><a href="about.html" title="tab2">About</a></li>
<li><a href="portfolio.html" title="tab3">Portfolio</a></li>
<li><a href="blog.html" title="tab4">Blog</a></li>
</ul>

<!--A wrapper for each tab content-->

<div id="content">
</div>
<!--end content div-->

<footer> <!--footer starts here-->

<div id="tab3">
<!-- change width to 100% and remove height-->
<table border="0" width="100%">
<tr>
<td><a href="index.html"><img src="images/logoicon.png"/></a></td>
<td><a href="index.html">Home | </a> <a href="about.html">About | </a> <a href="portfolio.html">Portfolio | </a> <a href="blog.html">Blog</a></td>
<td align="right"><small>&copy;copyright 2016 Kieron Roberts</small></td>
</tr>
</table>

</div>


</footer> <!--end of footer-->

CSS:

body {
/*width: 800px;*/ /*deleted*/
/*margin: 100px auto 0 auto;*//*deleted*/
background: darkgrey;
font-family: arial;
display: block;
}

#header {
width: 800;
height: auto;
margin: 0;
background: transparent;
}
/*
#h1.logo {
position: absolute;
right: 50px;
}*//*deleted*/

#tabs{
overflow: hidden;
width: 100%;
margin: 0;
padding: 0;
list-style: none;
}

#content
{
background: #fff;
padding: 2em;
height: 520px;
position: relative;
z-index: 2;
border-radius: 0 5px 5px 5px;
box-shadow: 0 -2px 3px -2px rgba(0, 0, 0, .5);
}

#tab2 {
position: relative;
}

#icons img {
padding-right:5px;
0% { /* space between content and footer*/
position: absolute;
top: 20;
right: 50px;
}

}
footer {
display: inline-block;
width:800px;
text-align: left;
/* margin-top: 250px;*//*deleted*/

}

footer ul {list-style-type: none;
text-align: center;
float: left;
}

footer li {display:inline;
}

footer a:link{
text-decoration: none;
}

footer p {
float:right;
}

table {border: solid darkgrey thin;
position: relative;
/*left: -100px;*//*deleted*/
z-index: 2;}


/*added*/
.logo{

text-align: center;
}

This how it should look like

关于html - Logo 不会在标题标签内向左或向右移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40832764/

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