我正在制作一个响应式着陆页,但我在修改Android和iOS的HTML元素时遇到了麻烦。例如:我更改了h1的字体大小,但它在iOS上没有变化,但在Android上却发生了变化。
下面是我的代码:
Style.css:
.first-container {
background-image: url("../../../assets/images/desktop/Img\ Head\ desktop.png");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: start;
justify-content: center;
padding: 0px 18rem;
h1 {
font-size: 3.5vw;
font-weight: 700;
}
p {
padding-top: 2rem;
padding-bottom: 2rem;
font-size: 1.25vw;
text-align: justify;
}
}
.title-first-container {
font-size: 1.3rem;
@media screen and (max-width: 400px) {
font-size: 1.5rem;
}
}
.subtitle-first-container {
font-size: 1.3rem;
@media screen and (max-width: 400px) {
font-size: 1.5rem;
}
}
.first-container-button {
background-color: #cc2c2c;
color: white;
border: none;
border-radius: 5px;
padding: 15px 60px;
font-size: 1.2rem;
cursor: pointer;
}
@media screen and (max-width: 768px) {
.first-container {
background-image: url("../../../assets/images/mobile/Img\ Head\ Mobile.png");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0rem 4rem;
button {
width: 100%;
}
}
.first-container-button {
background-color: #cc2c2c;
color: white;
border: none;
border-radius: 5px;
padding: 15px 60px;
font-size: 1.2rem;
cursor: pointer;
}
}
@media screen and (max-width: 400px) {
.first-container {
background-image: url("../../../assets/images/mobile/Img\ Head\ Mobile.png");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0rem 4rem;
button {
width: 100%;
padding: 8px 20px;
}
}
.first-container-content {
transform: translate(0px, 30%);
}
}
字符串
index.js:
<div className="first-container">
<div className="first-container-content">
<div className="title-first-container">
<h1>Cuide do seu <span style={{ color: 'rgba(207, 57, 57,1)' }}>coração.</span></h1>
<h1>Eu te ajudo!</h1>
</div>
<h2 className="subtitle-first-container">
Dr. Maurício Medeiros <br />
Cardiologista <br />
CRMCE:9091 RQE:11103
</h2>
<p className="description-first-container">
Médico Cardiologista, formado em 2003 pela <br />
Universidade Federal do Ceará. Professor de <br />
cardiologia da faculdade UNINTA. <br />
Ecocardiografista pela Escola Pernambucana de <br />
Ecocardiografia. Título de especialista pela <br />
Sociedade Brasileira de Cardiologia (RQE 11103). <br />
Proprietário e diretor clínico da CENTROCARDIO <br />
SOBRAL, uma clinica especializada em <br />
cardiologia na cidade de Sobral- Ceará.
</p>
<a href={linkButton} target="_blank" rel="noreferrer">
<button className="first-container-button">Agendar consulta</button>
</a>
</div>
</div>
型
我主要是想让iPhone 12上的H1的尺寸比H2大,将文本居中,并给予元素之间的最小距离。
1条答案
按热度按时间pb3skfrl1#
好吧,首先,正如其中一条评论所说,除非你使用Sass/Scss的React,否则我真的不会使用CSS嵌套。
第二,我相信你的问题可能在于
400px
部分,有手机屏幕比这更宽,我一直使用500px
,只是为了安全起见