gpt4 book ai didi

html - 居中 img

转载 作者:行者123 更新时间:2023-11-27 23:33:02 26 4
gpt4 key购买 nike

我需要将一个 img 居中(带有 class=“key”的那个,但是 float 元素阻止了它。我应该使用什么技术将其居中?

谢谢!

GitHub 存储库:https://github.com/CalogerN/beta-sign-up-split-layout

实时预览:https://calogern.github.io/beta-sign-up-split-layout/

body {
margin: 0px;
padding: 0px;
font-size: 16px;
}

header {
background-image: url(../img/bg-intro.svg);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 643px;
}

.logo {
float: left;
}

.wlogo {
fill: white;
}

.key {
height: 234px;
position: relative;
top: 200px;
}

.key-wrapper {
display: block;
margin: auto;
}
<section class="section-a">

<header>

<svg width="120" height="35" class="logo" *numbers* </svg>

<div class="key-wrapper">

<img src="img/illustration-main.svg" alt="a man with a key" class="key">

</div>

</header>

最佳答案

试一试:

HTML 结构:

 <header>
<div class="svg-wrap">
<svg width="120" height="35" class="logo" *numbers*="" <="" svg=""></svg>
</div>
<div class="key-wrapper">
<img src="img/illustration-main.svg" alt="a man with a key" class="key">
</div>
</header>

CSS 结构:

  body {
margin: 0px;
padding: 0px;
font-size: 16px;
}
header {
background-image: url(../img/bg-intro.svg);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 643px;
}
.wlogo {
fill: white;
}
.svg-wrap {
text-align: center;
margin: 0 auto;
}
.key {
height: 234px;
position: relative;
top: 200px;
}
.key-wrapper {
display: block;
margin: auto;
}

注意:只需包裹应用必须设置为居中对齐的 CSS 的 SVG 标签的 div。

关于html - 居中 img,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57387452/

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