gpt4 book ai didi

html - 如何将图像居中放置在页眉左侧?

转载 作者:行者123 更新时间:2023-11-28 01:38:27 25 4
gpt4 key购买 nike

我正在为一个学校元素制作一个 HTML 网站,我想将一张图片放在页眉左侧的中央。通过标题,我的意思是说世界矢量控制的大事。我将图像向左浮动,但由于某种原因它只是停留在左上角。

body {
background-color: #252525;
margin: 0;
font-family: ultra;
}

.navbar {
overflow: hidden;
background-color: #333;
font-family: ultra;
}

.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

.dropdown {
float: left;
overflow: hidden;
}

.dropdown .dropbtn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}

.navbar a:hover,
.dropdown:hover .dropbtn {
background-color: #2E86C1;
}

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}

.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

.dropdown-content a:hover {
background-color: #2E86C1;
}

.dropdown:hover .dropdown-content {
display: block;
}

.navbar .search-container {
float: right;
}

.navbar input[type=text] {
padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}

.navbar .search-container button {
float: right;
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: ;
font-size: 17px;
border: none;
cursor: pointer;
}

.navbar .search-container button:hover {
background: #ccc;
}

@media screen and (max-width: 600px) {
.navbar .search-container {
float: none;
}
.navbar a,
.navbar input[type=text],
.navbar .search-container button {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.navbar input[type=text] {
border: 1px solid #ccc;
}
}

.header {
background-color: #252525;
padding: 10px;
text-align: center;
color: blue;
margin 0;
}

h1 {
color: #2E86C1;
font-size: 60px;
font-family: ultra;
}

img {
float: left;
}

#rcorners1 {
margin: 50px auto;
padding-top: 100px;
border-radius: 25px;
background: #fffafa;
padding: 20px;
width: 90%;
height: ;
}
<div class="header">
<img src="Untitled-2.png" alt="M" width="80" height="80">
<h1>World Vector Control</h1>
</div>

<div class="navbar">
<a href="#home">Home</a>
<a href="#news">About</a>

<div class="dropdown">
<button class="dropbtn">
Introduction
<i class="fa fa-caret-down"></i>
</button>

<div class="dropdown-content">
<a href="#">The Problem</a>
<a href="#">The Solution</a>
</div>
</div>

<a href="#FAQ">FAQ</a>

<div class="dropdown">
<button class="dropbtn">
Contact Us
<i class="fa fa-caret-down"></i>
</button>

<div class="dropdown-content">
<a href="#">Donate</a>
<a href="#">Get Invovled</a>
</div>
</div>

<div class="search-container">

<form action="/action_page.php">

<input type="text" placeholder="Search..." name="search">

<button type="submit">
<i class="fa fa-search"></i>
</button>

</form>

</div>
</div>

<p id="rcorners1">Rounded corners!</p>

最佳答案

试试这个:

<img src="Untitled-2.png" alt="M" width="80" height="80" style="left:30px;">

关于html - 如何将图像居中放置在页眉左侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50556733/

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