有Zeplin的要求,我需要在屏幕左侧显示一幅图像并使其具有响应能力,到目前为止,我未能使其具有响应能力,因此我需要在正确方向上提供一些帮助 我将为自己成功做过一幅画。
我将粘贴CSS的代码
.sign-in-image {
width: 40%;
height: 100vh;
float: left;
border: solid 1px #979797;
background-repeat: no-repeat;
background-size: contain;
我的注册反应代码
const SignIn = () => (
<div className="sign-in">
<div className="image-container">
<div className="sign-in-image" style={{ backgroundImage: `url(${signin})` }} src = {signin} alt="logo" />
</div>
<div className="right">
<input className='textField' placeholder="Username" />
<input className='textField' placeholder="Password" />
<button type="button" className='signIn'>sign in</button>
<p className='forgot'>Forgot username or password</p>
<p className='signUp'>Don’t have an account? Sign up</p>
</div>
</div>
)
export default SignIn;
css文件
.sign-in-image {
width: 40%;
height: 100vh;
float: left;
border: solid 1px #979797;
background-repeat: no-repeat;
background-size: cover;
}
.right{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
.textField{
height: 47px;
width: 600px;
outline: 0;
border-width: 0 0 2px;
border-color: #f1f1f1;
margin-top: 44px;
text-align: center;
border-bottom:thin dashed grey;
}
.textField::placeholder{
width: 600px;
height: 47px;
}
.signIn{
width: 100px;
height: 48px;
border-radius: 24px;
background-color: #f1316b;
color: #fff;
margin-top: 45px;
border: 0;
}
.forgot{
font-size: 18px;
font-weight: normal;
font-stretch: normal;
font-style: italic;
line-height: normal;
letter-spacing: normal;
color: #2e1150;
font-family: 'Nunito';
margin-top: 60px;
width: 241px;
height: 24px;
}
.signUp{
font-size: 20px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
line-height: normal;
letter-spacing: normal;
color: #2e1150;
margin-top: 187px;
}
@media only screen and (max-width: 768px){
.sign-in-image {
width: 60%;
height: 100vh;
}
}
@media only screen and (max-width: 640px){
.sign-in-image {
width: 60%;
height: 100vh;
}
}
我希望有人可以引导我朝正确的方向做出回应,而不会被图片吞噬 谢谢
答案 0 :(得分:0)
您可以使用媒体查询:
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {...}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {...}
/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {...}
为相应的设备或宽度相应地应用css。