首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >div中的响应式图像响应式?

div中的响应式图像响应式?
EN

Stack Overflow用户
提问于 2021-02-25 19:30:14
回答 1查看 65关注 0票数 0

我正在建立我的第一个真正像样的网站基本上,我正在创建一个背景自动柜员机与一些css和一个图像,我想做它就像它在图片中

..。(已经完成了),但它不响应,可能是因为位置:绝对属性,我想让它正确响应。

下面是我用作后台的HTML代码​

代码语言:javascript
复制
.bg {
  background: #9359C7;
  color: white;
  display: grid;
  text-align: center;
  height: 764px;
  width: 1280px;
}

.content {
  position: relative;
}

.content img {
  width: auto;
  height: auto;
  position: absolute;
  right: -178px;
  bottom: 0;
}
代码语言:js
复制
Lol

编辑:我把我的整个网站都放在上面了patebin由于idk不允许我上传到这里,我得到的代码片段至少对我不起作用。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-25 20:55:25

这应该会起作用:

代码语言:javascript
复制
body {
  font-family: sans-serif;
  margin: 0;
  padding: 0;
}

.hero {
  position: relative;
  overflow-x: hidden;
}

header {
  position: relative;
  background: black;
  padding: 40px 0;
  z-index: 5;
}

.content {
  position: relative;
  z-index: 5;
  color: white;
  text-align: center;
  width: 70%;
  height: 100vh;
  max-height: 768px;
  background: #9359C7;
  padding: 20px;
}

img {
  width: auto;
  height: 98%;
  position: absolute;
  right: 30%;
  bottom: 0;
  transform: translateX(50%);
  padding-top: 80px;
  z-index: 10;
}

h1 {
  margin: 0;
}
代码语言:js
复制
Lol

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66367646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档