I am trying to make two compositions that are vertically responsive at browser resize. I have an example here and I am using Adobe Muse.
The red box and blue box is what I am trying to achieve in terms of responsive when you resize the browser vertically. The green square is a composition that has no text in it and it behaves as it should. However, when I add text, it happens what you see in the dark blue button with text. How can I make the text inside the composition vertically centered and still behave like the green, red or blue box?
The code I added so far for all of them is:
<style>
.redbox {
height: 50vh !important;
min-height: 50vh !important;
position: relative;
}
.bluebox {
height: 50vh !important;
min-height: 50vh !important;
position: relative;
}
.green-button {
height: 50vh !important;
min-height: 50vh !important;
position: relative;
}
.darkblue {
display: block;
height: 50vh !important;
min-height: 50vh !important;
position: relative;
}
</style>
Thank you!!!
If I have understood correctly, you want to center text on a div regardless of the div height. You can do it with flexbox, or with absolute positioning.
I recommend the first option. with a
display: flexandalign-items: center;in div, it would be enough to center the contents inside the container.However, if the text is too long, you should add mediaquerys to change the font size to adapt it to the screen size, or at a certain minimum height, set the height of the divs fixed with min-heigh in pixels, for example.
Example flexbox and absolute positioning
Edit
So you are looking for something like this:
Example