gpt4 book ai didi

html - 定位文本和图像?

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

这是我的代码:http://jsfiddle.net/vy6w2tun/1/

<html>
</html>

(1)文字在页面居中,这就是我想要的。

(2) 但是,我希望图像居中(确实如此),但我不希望文本覆盖图像。我希望图像位于文本下方,这样图像的任何部分都不会被文本覆盖,反之亦然。

我该怎么做呢?

最佳答案

我从 p { } 中删除了 position:absolute;top left 值和 transform 值。 © 在 p {} 中添加了 margin:0 auto;(对于中心)和 width:70%;

<html>

<head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box
}

body {
margin: 0;
padding: 0
}

@font-face {
font-family: HelveticaNeueLTCom-Th;
src: url("HelveticaNeueLTCom-Th.ttf")
}

p {
font-family: HelveticaNeueLTCom-Th;
font-size: 19pt;
letter-spacing: 1.2px;
color: red;
line-height: 1.5;
text-align: justify;
margin:0 auto;
width:70%; /* it's up to you */
}

.fullscreen-bg {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
z-index: -100
}

.fullscreen-bg__video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%
}

.img {
display: grid;
height: 100%
}

.center-fit {
max-width: 100%;
max-height: 90vh;
margin: auto
}

@media (min-aspect-ratio: 16/9) {
.fullscreen-bg__video {
height: 300%;
top: -100%
}
}

@media (max-aspect-ratio: 16/9) {
.fullscreen-bg__video {
width: 300%;
left: -100%
}
}
</style>
</head>

<body>
<div class="fullscreen-bg">
<video loop autoplay muted src="video.mp4" type="video/mp4" class="fullscreen-bg__video"></video>
</div>
<p>In publishing and graphic design, lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content. Replacing the actual content with placeholder text allows designers to design the form of the content before the content itself has been produced.</p>
<div class="img"> <img class="center-fit" src='https://grcc.net/wp-content/uploads/2015/06/Dogs-for-Rob-1-e1434850228704-1024x695.jpg'></div>
<div class="img"> <img class="center-fit" src='https://picsum.photos/400/300'></div>
<div class="img"> <img class="center-fit" src='https://picsum.photos/400/300'></div>
</body>

</html>

关于html - 定位文本和图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53998485/

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