ok, what I want to do is pretty complex and I am having a lot of difficulty. I find HTML is so difficult to get looking just right and makes no sense!
I am trying to do a profile page, with a user image, name and a button.
here is my code:
<div class="container" style="background-color:yellow">
<div style="display:inline-block;height:140px;width:140px;background-color:red"></div>
<label> <b> User Name</b> </label>
<button style="float:right">add friend</button>
</div>
so, I have 2 issues:
#1: I want the button to be on the right side of the screen, but on the same line as the text for the label saying "Name".
#2: I want to be able to resize the screen and have the elements reposition properly. when there is no room for them, I want them to go underneath each other and become centered. here is and image example:
is it possible to do this with html and css alone? do need to check the window size with javascript and reposition elements? If so, can I at least get the float right element to position properly with HTML?
any help is appreciated! thank you!
3
Answers
I’d recommend CSS flexbox for doing this. Its great for doing responsive designs.
To solve your problem easier, i moved the CSS in an external file.
My CSS:
My HTML:
Learn more about CSS Flexbox:
https://www.w3schools.com/css/css3_flexbox.asp
I wrote the easiest way to do this below