【发布时间】:2020-08-17 11:04:03
【问题描述】:
我是一名全栈开发人员,但 css 是我的弱点,所以我决定在这方面付出更多努力。我有一个奇怪的情况,无法弄清楚为什么。问题是我无法正确调整图像的高度和宽度。我正在使用 reactstrap、bootstrap 和 scss,但我确保引导代码不会覆盖我的 css:
import "bootstrap/dist/css/bootstrap.min.css";
import "../styles/main.scss";
这里是html部分:
<Col md="6">
<div className="hero-section">
<div className={`flipper ${isFlipping ? "isFlipping" : ""}`}>
<div className="front">
<div className="hero-section-content">
<h2> Full Stack Web Developer </h2>
<div className="hero-section-content-intro">
Have a look at my portfolio and job history.
</div>
</div>
<img
alt="programming welcome picture"
className="image"
src="/images/original.png"
/>
<div className="shadow-custom">
<div className="shadow-inner"> </div>
</div>
</div>
</Col>
这里是相关的css代码:
.hero-section {
h2 {
color: black;
font-weight: bold;
margin-bottom: 10px;
}
perspective: 10rem;
color: black;
font-weight: bold;
width: 40rem;
position: relative;
&-content {
position: absolute;
bottom: 20px;
width: 360px;
left: 6%;
z-index: 1;
&-intro {
font-size: 17px;
}
}
}
.image {
max-width: 100%;
// background-size: cover;
max-height: 50%;
position: relative;
background-position: center;
}
但是有了这个 .image
.image {
max-width: 100%;
// background-size: cover;
// max-width: 100%;
max-height: 100%;
position: relative;
background-position: center;
}
我也有同样的看法。如果我改变宽度,高度就会改变,但我只想改变高度。
图片 css 我有这个
用这个.image
.image {
max-height: auto;
max-width: 100%;
background-position: center;
background-size: cover;
}
我在图像之外获取文本 :( 即使 max-width: 100% 它没有第一张图像那么宽 :(
【问题讨论】:
标签: javascript css reactjs sass next.js