下面是我的代码:http://jsfiddle.net/vy6w2tun/1/
<html>
</html>(1)文本在页面居中,这就是我想要的。
(2)但是,我希望图像居中(确实如此),但我不希望文本覆盖图像。我希望图像在文本下面,这样图像的任何部分都不会被文本覆盖,反之亦然。
我该怎么做呢?
发布于 2019-01-02 03:59:26
我从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>
https://stackoverflow.com/questions/53998485
复制相似问题