Can I change the buttons that the second button goes into another ‘line’ when the sreen is too small in HTML? look:
I want the Join a lobby button in the second picture to break into a new line. Here’s my HTML code
.Container {
display: flex;
align-items: center;
justify-content: center;
gap: 30px;
}
.ModeButton {
color: #ffffff;
background: linear-gradient(90deg, #65F78C 0%, #54E051 35%, #96FC5B 100%);
border: 0px;
font-size: 30px;
border-radius: 15px;
font-family: 'M PLUS 1p', sans-serif;
width: 500px;
height: 350px;
opacity: 1;
transition: color, opacity 0.3s linear 0s;
}
<div class="Container">
<button type="button" class="ModeButton">
Create a new lobby
<br>
<br>
<img src="images/Create.png">
</button>
<button type="button" class="ModeButton">
Join a lobby
<br>
<br>
<img src="images/Join.png">
</button>
</div>
3
Answers
You can simply use media query and can change
flex-direction
property on .ContainerCheckout CSS Flexbox for more understanding.
Use
flex-wrap
withflex-basis
value for wrappingflexbox
supports a natural wrapping behavior, which allows the flex items to wrap as needed when the content area become smaller. You might want to use aflex-basis
value for preferred base width for your flex children.See the example snippet below.
You can add a flex-direction: column to your container class when you’re using smaller screens using media queries so they will stack vertically.