5
There are several ways to do it. Here is a simple example with Flexbox
.
This model works like this, using the media query @media
when the screen is larger than 660px
with the flex-basis
I determine that the right column will have 70%
and the right 30%
, When the screen is smaller than 660px
every column gets 100%
of flex-basis
, so each column occupies an entire row.
Code with the image result above:
OBS: Display under "Whole Page" to better see how responsive it is. If I want to adjust the width of the columns just adjust proportionally the 70% and 30% always adding up to 100%, Ex: 75%, 25%
* {
box-sizing: border-box;
}
.container {
display: flex;
flex-wrap: wrap;
}
.esq {
flex-basis: 70%;
background-image: radial-gradient(transparent, rgba(0,0,0,0.9)), url(https://unsplash.it/360/200);
background-size: cover;
}
.dir {
flex-basis: 30%;
background-color: aliceblue;
}
@media screen and (max-width: 660px) {
.container > div {
flex-basis: 100%;
}
}
<div class="container">
<div class="esq">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione, sed?
</div>
<div class="dir">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione, sed?
</div>
</div>
TIP: as a matter of curiosity
In this case in specific vc tb can use the technique known as Flex-Grow 9999 Hack with her you can make the columns break no need for media query! Here you can read more about it: https://joren.co/flex-grow-9999-hack/
See the code used to get the image result above:
.container {
display: flex;
flex-wrap: wrap;
}
.cell {
display: flex;
align-items: center;
height: 100px;
}
.first {
flex-grow: 1;
background-color: lightgreen;
flex-basis: 70%;
min-width: 320px;
}
.second {
flex-grow: 9999;
flex-basis: 30%;
background-color: lightblue;
}
<div class="container">
<div class="cell first">
Cell 1
</div>
<div class="cell second">
Cell 2
</div>
</div>
Hello, welcome to stackoverflow en! Try to post along with your question some code you have already tasted. But I think what you’re looking for is called responsiveness.
– Um Programador
I suggest you use Bootstrap, with it you can do it for both desktop and mobile.
– Renan
@Renanosorio why use Bootstrap for this? For which you will import a 90kb Framework if you can solve this with less than 10 CSS lines?
– hugocsl
Bootstrap will help not only to make this login screen, but for future structures that it may need for both mobile and desktop, in these cases you have a framework ready, no need to remake something that is already ready.
– Renan
Hello, welcome to stackoverflow! : D Just a hint for your next questions, avoid using links to, examples or code, as it may occur the link becomes inactive. So you stop helping others. ;)
– codermarcos