Making column's height adjust to an image's responsive height(Flexbox ) - html

I have this piece of code and I need to make 2 separate results :
https://jsfiddle.net/29Lxsq1m/
1. Make the left and right divs(l0,r0) adjust to image height
2. Align the image to the center
I have tried to achieve the 2nd scenario with various but nothing seems to work excuse if these are dumb q's but I have been trying to make this 5 hours now and my mental can't handle this anymore I am also open to a way of solving my problem not using Flexbox
.container {
width:100%;
height:1000px;
display:flex;
}
.l0 {
width: 249px;
flex: 0 0 249px;
height:100%;
overflow:auto;
}
.c0 {
width:100%;
height:100%;
}
.r0 {
width: 249px;
flex: 0 0 249px;
height:100%;
overflow:auto;
color:white;
}
img {
max-width:100%;
}
#mid {
display: flex;
justify-content: center;
align-items: center;
}
<div class="container">
<div class="l0">
<center>
text....
</center>
</div>
<div class="c0">
<img src="gifS.png" id="mid"> /* 1920x1080 img */
</div>
<div class="r0">
text....
</div>
</div>

The max-width: 100% on the img element causes the image to stop scaling at 100% size. Also, when the container shrinks, the image changes its width to fit the container, thereby reducing its height.
To solve this, set the width and height of the image so that it is always the same size as the container, and adjust the display method of the image by applying the object-fit property as appropriate.
#mid {
width: 100%; /* add */
height: 100%; /* add */
object-fit: cover; /* add */
}
#font-face {
font-family: Open-sans;
src: url(OpenSans-Light.ttf);
}
body {
font-family: Open-sans;
background-color: grey;
background-repeat: repeat-y;
background-size: 100%;
}
.container {
width: 100%;
height: 1000px;
display: flex;
}
.l0 {
width: 249px;
flex: 0 0 249px;
height: 100%;
overflow: auto;
}
.c0 {
width: 100%;
height: 100%;
}
.r0 {
width: 249px;
flex: 0 0 249px;
height: 100%;
overflow: auto;
color: white;
}
img {
max-width: 100%;
}
#mid {
display: flex;
justify-content: center;
align-items: center;
width: 100%; /* add */
height: 100%; /* add */
object-fit: cover; /* add */
}
<div class="container">
<div class="l0">
<center>
Όποιος θεός κι αν είναι <br> έδωσε δώρο μητέρα γη<br>
<br> το τιμάς το δώρο τούτο <br> αν άξιος πάνω της περιπατείς <br>
<br> αν όλους εδώ μας θέλησε,<br> πνοή ζωής μας έδωσε,<br>
<br> αναπνοή, ολόκληρη μισή<br>
<br> ύδωρ και γη μελέτησε,<br> τη φύση παράδειγμα και δώρο, <br>
<br> ένα τραγούδι άφησε,<br> μια μελωδία ολόγυρα, <br>
<br> τα λόγια η φύση τραγουδά, <br> τα τραγουδά εις άπειρο, <br>
<br> είναι γραμμένα εδώ, <br> είναι το δείγμα ολόγυρα, <br>
<br> και σαν μην έφτανε αυτό,<br> έδωσε κι άλλο δώρο<br>
<br> μια σκέψη, πλασμένη <br> από αγάπη, ολόκληρη μισή <br>
<br> αν υπάρχουν, καλύτερα από τούτα<br> πες μου αν μπορείς,<br>
<br><br> θυμήσου μόνο,<br>
<br> πνοή ζωής έπήρες δώρο,<br> αγάπη, ολόκληρη μισή.<br>
<br> και εμείς ;<br>
<br> μην είμαστε <br> Αδέλφια, πατέρες, μητέρες,<br> παιδιά όλοι, των ίδιων <br> εμείς ;<br>
<br> οικογένεια μια, να λέγαμε <br> μια στέγη, μαζί <br>
<br> ένα να είμαστε <br> παιδιού μικρού, ψυχή <br>
<br> ο κόσμος παράδεισος ένας, <br> όμορφος από ότι έχουμε φανταστεί<br>
<br> μη λόγο να βάλουμε <br> όρκο να πάρουμε, <br>
<br> εμείς ;<br>
<br> μοναχά καλό να υπάρχει <br> να ζηλεύουν τα όνειρα κάθε στιγμή<br>
<br> μπουκέτα λουλούδια <br> μες τη καρδιά μας <br> ερωτευμένοι κάθε στιγμή <br>
<br> μη λόγο να πράτταμε <br> σκέψη και αγάπη να βάζαμε, <br>
<br> εμείς ;<br>
<br> όρκο θα πάρουμε μητέρα γη<br>
<br>
</center>
</div>
<div class="c0">
<img src="https://via.placeholder.com/500x1000/ffffff/888888/500x1000.png" id="mid">
</div>
<div class="r0">
<center>
He who has a Why to live can bear almost any how.<br>
</center>
scriver: -Friedrich Wilhelm Nietzsche<br>
<center>
<br> *
<br>
<br> He who can properly define and divide <br> is to be considered a god
<br>
</center>
scriver: Plato
<center>
<br> *
<br>
<br> Before cure someone, <br> (mentally or physically) ask him if <br> he is willing to let go all those things <br> that make him sick <br>
</center>
-Hippocrates <br>
<center>
<br> *
<br>
<br> A work of art is the unique <br> result of a unique temperament. <br> Its beauty comes from the fact that <br> the author is what he is. <br> It has nothing to do with the fact <br> that other people want what they want.<br>
</center>
-Oscar Wilde<br>
<center>
<br> Happy is the man that findeth wisdom, <br> and the man that getteth understanding.<br>
<br>
</center>
scriver: -Proverbs <br>
<center>
<br>
<br> Ask yourself what is really important <br> and then have the courage <br> to build your life around your answer.<br>
<br>
</center>
scriver: unknown <br>
<center>
<br>
<br> Know thyself.<br>
<br>
</center>
scriver: Socrates<br>
<center>
<br>
<br> Integrity is doing the right thing <br> even when no one is watching. <br>
<br>
</center>
scriver: C.S. Lewis<br>
<center>
<br>
<br> If a movement is to have an impact, <br> it must belong to those who join it, <br> not only those who lead it. <br>
</center>
scriver: -Simon Sinek<br>
<center>
<br>
<br> It is the individual who is not interested <br> in his fellow ,men, <br> who has the greatest difficulties in life and <br> provides the greatest injury to others. <br> It is from among such individuals <br> that all humans failures spring.<br>
<br>
</center>
scriver: Alfred Adler<br>
<center>
<br>
<br> The more diverse the plant foods we eat <br> the more diverse our gut microbiome becomes <br> and the more abundant our health is.<br>
<br>
</center>
scriver: Dr. Will Cole<br>
<center>
<br>
<br> He who can properly define <br> and divide is to be considered a god<br>
<br>
</center>
scriver: Plato <br>
<center>
<br>
<br> The moment you change your perception, <br> is the moment you rewrite the chemistry of your body.<br>
<br>
<br> Love is a gift to be used every day,<br> Not be smothered and hidden away. <br> Love is not a thing to be stored <br> in the chest where you gather your keepsakes, <br> And treasure your best. <br> Love is a gift to be used every day.<br>
<br>
</center>
scriver: Norah Perkins<br>
<center>
<br>
<br> Before you cure someone, <br> ask him if he is willing to let go <br> all those things that make him sick.<br>
<br>
</center>
scriver: - Hippocrates <br>
<br>
</div>
</div>

Related

What is the problem of my h1 tag on iphone?

I have my mobile only website. I am testing on my Iphone 6. The problem is with my title h1 tag no showing when you load. It reappears after you resize the screen and scroll past it. Can anyone help? Please and Thanks. Code:
https://github.com/SEGACD32XMODEL1/Websiteland/blob/master/mobile.html
Site:
https://segacd32xmodel1.github.io/Websiteland/mobile.html
<span id="animationSandbox" style="display: block;">
<div id="grad1" id="topnav" class="myTopnav" class="site__title mega" style="text-align:center;margin:auto;color:#888888;font-size:6vh;font-weight:bold;font-family:oreos;line-height:0.5;overflow-wrap:anywhere;text-align:center;" height="150vh">
<h1 class="site__title mega" style="overflow-wrap: break-word;text-align:center;padding-top:0px;line-height:16vh"> Websiteland <br>
<div>
Cornhub
<br>
Federal Crimes
<br>
GamesAndMore
<br>
KahootSpam
<br>
Reload
<br>
Roasted Beef 420
<br>
School
<br>
Time
<br>
Uno Special Cards
<br>
Websites
</div>
</h1>
</div>

ASCII art distorts when zooming out on browser

I'm making an image to ascii art converter, which outputs an HTML file to allow formatting and easy zooming. The problem, however, is that when zoomed out in Chrome, the ascii image's height decreases less than its width and the image becomes distorted (too wide). I've tried playing with the line-height property to no avail. In Edge and IE there's no issue - zooming successfully keeps the aspect ratio.
Here's an example of the converter's HTML output with a low resolution, but the problem is accentuated the higher the resolution. Any help would be appreciated!
<!DOCTYPE html>
<html>
<body style="
COLOR:#000000;
TEXT-ALIGN:center;
FONT-SIZE:1px;
">
<p style="
white-space:pre;
FONT-FAMILY:Courier New;
FONT-SIZE:1.171875rem;
LETTER-SPACING:0.15em;
LINE-HEIGHT:0.400000em;
">
`MMMMMMMMMMMMMMM#BQBMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMME%SMMMMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMMc~~~1MMMMMMMMMMMMMMMMMMMMMMMMMMM#K$#G)//IQMMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMM&.`./5MMMMMMMMMMMMMMGJ?DMMMMMMB9{~~~(D+)//:A#MMMMMMMMMMMM` <br>
`MMMMMMMMMMMA)(.~~:#MMMMMMMMMMMMM%...+MMQdJ'~~~~~~~/+/'//'+KMMMMMMMMMMM` <br>
`MMMMMMMMMM3~/./+CHMMMMMMMMMMMMMM$~...:+~...~.~~~~~~/:5C:!'(HMMMMMMMMMM` <br>
`MMMMMMMMM4.7.`.~KMMMMMMMMMMMMMMH!.``........~~~~~~~~L!C547'?MMMMMMMMMM` <br>
`MMMMMMMMB``{```/"MMMMMMMMMMM"7~````.7.+........~~~~~!&c25/''%MMMMMMMMM` <br>
`MMMMMMMM!``'``.(BMMMMMMMMMMM:`````~':/L./'....~//~~~~4!&7//'(H#MMMMMMM` <br>
`MMMMMMQ:``````/CMMMMMMMMMMMMC`````.2``J.1~....~.~~~~~/5{////':'EMMMMMM` <br>
`MMMMMM2``````.)BMMMMMMMMMMMMD``.)``~``c.~:....~..~~~~~/////'//(!QMMMMM` <br>
`MMMMMC```````~CMMMMMMMMMMMMMQ.~$Q:```/.``/.......~~~~~/////~'')+"MMMMM` <br>
`MMMM$````````/GQMMMMMM#EQMMMM#%&!{````````.....~..~~~/~~/////'(+{BMMMM` <br>
`MMMM~````'````.'#MMME?LL$M#HSC+~~`````..........~.~~~.~~///'/''):LMMMM` <br>
`MMM"````.+`````~%MMM5&CC9SU&3J````````````......~~..~~~~/////+7(+:BMMM` <br>
`MMM/`).'+.`````/$MMMEJCCCCCCCJ````````````........~.~~~~/////C$+++5MMM` <br>
`MMK`.c:'/```/~/!##d313CCCCCCCC`````````````.``....~~~~~~~////12I)+7#MM` <br>
`MM:````+```/I$599L&&CCCCCCCCCC.``````````````......~~~~~~//(//9&)+:$MM` <br>
`MQ.```````.+CCCC&CCCCCCCCCCCCC/``````````````....~//.~~~~//+7/+4(+:2MM` <br>
`M%.```````~7CCCC&CCCCCCCCCCCCC7```````````./~2..~~...~~~~~//J?1U(+:{BM` <br>
`M!````````~1CCC33CCCCCCCC2:/~``````````.+c.{`+..~....~~~~~///2DI(){{KM` <br>
`M~````````~1CCCJJCCCCC7~` `````.`````/S~`L'/`+`.~..../~~~~/////''((:&M` <br>
`#`````````.//~....{CC2 `````.``````~4`.9~`(`..~../~/~~~/////(''+:1M` <br>
`K``````````````` `(CCC' `````.```````/3`)5~/`...///.~/~~///'')))(:{#` <br>
`&``.```````````` /&CCC: `````````````{c/~S.`.......~/~~~////':)):7R` <br>
`1``7/``````````` .CJ!~ `..`.`````````J(`/``.......~~~~~/////+)):!G` <br>
`+`./)~````````` ````````````````.````.......~~~//~///')+):7%` <br>
`'`.+!I````````` .``````````````````.........~~//~////'')!c79` <br>
`~`./.``.``````` `'/+C~ .````````````````...`..~...~//~~~////''!cI79` <br>
`/`.:&.````````` ?. .D. .```````````````.````..~.~~~.~/~/////'(c2I75` <br>
`/``+./````````` ." J7 ```.``.`````````.````..~~...~~~////'/'(??274` <br>
`/``14.``````````~S 7! ``.````.````````..```.......~~~/~/////({I?7U` <br>
`(`...````````````$. J. ```````````````````.``.......~~~///~/'/+???7%` <br>
`1````````````````~J. //./`````````.````````.```....'/~~~~~~///'/+{22{D` <br>
`J````````````````//?`+%&/`````````.``````..````..~?9.~~~~~////'')+cc7H` <br>
`S````````````````?I+``````````````.......````~:7..(G~~~~~~//'('():{{7B` <br>
`E`````````````````````````````````.``````````~4{..{%(~~~~~////'(+:{{1M` <br>
`M.````````````````````````````````.``````````.7C.//C!~~~~////'()+:!7CM` <br>
`M+````````.```````````````````````.``````````./$.{.!&~~~~////'()+:!{%M` <br>
`ML`)+`````.```````````````````````.`````````...G+'.'%/~~~//'/')++{{7EM` <br>
`MB`~`/````.`````````````.`````````.````...``...4J..+J'~~////)'++:7!IMM` <br>
`MM/~c/.```.`````````````.``````````.``.```.`...?L/.~~~~~////++)+:7!"MM` <br>
`MM4`~~?/``.````````````````````````...````.`..~+~.~~~/~////'()+:{52#MM` <br>
`MMQ.~+!.```.`````````.````````````````````.`.....~~.~/////''()+:&LCMMM` <br>
`MMM?.~/)````....`````7/`:++.``````````.........~..~~~//////()):7%UAMMM` <br>
`MMM#...(````````.````+7/c`3'`````````.````.......~~~~'////()++:JJLMMMM` <br>
`MMMM?``..```````````/+!~{)3~````````.```......~.~~~~~~///'()++{73HMMMM` <br>
`MMMMQ~.`````.````````7+I~!&.````````.``........~.~~~////'(+:+:7JSMMMMM` <br>
`MMMMM%..````.```````~!:.`I1c.```````..........~..~~////'')++:{7&BMMMMM` <br>
`MMMMMM{.````.````````(+/~c~?+~``````~..........~~CU%?/''(++::7!DMMMMMM` <br>
`MMMMMM#~````.````````/~~`+/.`````............~~~~4S%L'')++:{{!&MMMMMMM` <br>
`MMMMMMMR..`...````````````````...``..~......~~~~///7C'()7{:{72QMMMMMMM` <br>
`MMMMMMMM$...`......`````````..`......./...~~~~~////22()++:{7cBMMMMMMMM` <br>
`MMMMMMMMMU//....```````.```............~~.~~~~////'3!)++:{{!EMMMMMMMMM` <br>
`MMMMMMMMMM9/:..~.......................~~~~~/////''4+++:::!RMMMMMMMMMM` <br>
`MMMMMMMMMMM"/'..~...................~~~~~~~/////''(++++:{1#MMMMMMMMMMM` <br>
`MMMMMMMMMMMMd:+~.~................~..~~~~//////'''(+++:72BMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMBcc/........)7:'/.~~~~~~~~/'////''(()++::{LQMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMMQ9/~~~~~.~~~/:~~//~~///''//)//'''()+7?1?KMMMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMMMME:~///~~~~)(~~~/!~///////'/''()+:7J!4#MMMMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMMMMMMG+~~//~~(:)c:{9(///////''()++?IICEMMMMMMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMMMMMMMMG7/////'{(/)'/////''(++::+:73RMMMMMMMMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMMMMMMMMMMB5+'//////'/('''(():+++I%#MMMMMMMMMMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMMMMMMMMMMMMMB$C!(/'''2?J:))+c5d#MMMMMMMMMMMMMMMMMMMMMMMMM` <br>
`MMMMMMMMMMMMMMMMMMMMMMMMMMMMMQBHG$%%$KR#MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM` <br>
</p>
</body>
</html>

Centering A Div in the middle of a page [duplicate]

This question already has answers here:
How can I horizontally center an element?
(133 answers)
How can I vertically center a div element for all browsers using CSS?
(48 answers)
How do you easily horizontally center a <div> using CSS? [duplicate]
(22 answers)
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
Closed 4 years ago.
The middle body text won't center, and I don't know why. Also, if you have any other recommendations, they would be greatly appreciated! This is for a project and I just need a little help. I am using the margin:auto property, but it doesn't seem to work.
body {
margin:10px;
background-color:white;
}
/* Unordered List */
ul {
border:1px solid green;
width:750px;
}
/* Lists styles */
li {
font-weight:bold;
}
.test-div {
width:500px;
height:250px;
background-color:#f2f2f2;
display:block;
margin-left:auto;
margin-right:auto;
}
#body-text {
width:500px;
display:block;
margin-right:auto;
margin-left:auto;
}
/* Divider is 1.5 times shorter than header - 750/1.5 = 500 */
.divider {
background-color:black;
width:500px;
height:1px;
}
.text-center {
display:block;
margin-right:0px auto;
margin-left:0px auto;
}
.centered {
display:block;
margin-right:auto;
margin-left:auto;
text-align:center;
}
.link {
text-decoration:none;
margin-left::auto;
margin-right:auto;
}
.link:hover {
text-decoration:none;
color:#00008B;
}
#footer {
text-align:center;
width:800px;
height:500px;
padding:25px;
border:2px solid green;
margin:0 auto;
}
.filler {
height:100px;
}
ul .divider {
margin-right:auto;
margin-left:auto;
}
<head>
</head>
<script>
</script>
<div class="text-center" style="display:block;margin-left:auto;margin-right:auto;background-color:#f2f2f2;width:750px;height:450px;border-radius:15px;">
<img src="https://blog.adioma.com/wp-content/uploads/2016/02/how-elon-musk-started-infographic-700x466.png" alt="Elon Musk Wealth Sahre Joke" style="width:480px;height:380px;margin-left:10; margin-top:20px"/>
<br>
<em style="font-size:11px;"> Elon musk wealth Share - Joke </em>
</div>
<div id="body-text">
<ul class="text-center" style="list-style-type:none;">
<br>
<div class="centered" style="width:300px;height:40;border:1px solid black;padding-top:10px;">
<h1 style="font-family:monospace"> <em> A Life of Work </em> </h1>
<p> <u> A Timeline of Elon Musk's Life life </u> </p>
</div>
<br>
<li>June 28, 1971 - Born in South Africa </li>
<br>
<div class="divider"> </div>
<br>
<li> Taught himself how to code at age 12</li>
<br>
<div class="divider"> </div>
<br>
<li> Creates and writes a video game called Blastar; sells it for the equivalent of $500 </li>
<br>
<div class="divider"> </div>
<br>
<li> 1988: Graduates from Pretoria Boys High School with distinctions in science and computer studies </li>
<br>
<div class="divider"> </div>
<br>
<li>1989 to 1991: Attends college at Queen’s University in Kingston, Ontario. Then transfers to the University of Pennsylvania; completed a BS in Economics (Wharton) and a BA with a major in physics </li>
<br>
<div class=divider> </div>
<br>
<li> 1995: Moves to Silicon Valley; defers graduate program in applied physics and materials science at Stanford University to join the Internet boom </li>
<br>
<div class="divider"> </div>
<br>
<li> February 1999: Sells Zip2 to Compaq, the personal computer company, for $307 million, of which $22 million went to Musk. Then forms X.com, which in 2000 morphs into PayPal </li>
<br>
<div class="divider"> </div>
<br>
<li> July 2002: eBay acquires PayPal for $1.5 billion in stock, of which $165 million goes to Musk </li>
<br>
<div class="divider"> </div>
<br>
<li> 2002: Becomes an American citizen </li>
<br>
<div class="divider"> </div>
<br>
<li> 2002: Founds SpaceX9 </li>
<br>
<div class="divider"> </div>
<br>
<li> 2004: Invests in Tesla Motors </li>
<br>
<div class="divider"> </div>
<br>
<li> 2007: SpaceX wins $1.6 billion contract to bring cargo to the International Space Station </li>
<br>
<div class="divider"> </div>
<br>
<li> October 2008: Becomes Tesla’s CEO </li>
<br>
<div class="divider"> </div>
<br>
<li> Jun 29, 2010: Tesla IPO </li>
<br>
<div class="divider"> </div>
<br>
<li> May 2012: SpaceX becomes the first commercial vehicle to deliver a load of supplies to the International Space Station. </li>
<br>
<div class="divider"> </div>
<br>
<li> June 2012: Tesla begins deliveries of the all-electric Model S </li>
<br>
<div class="divider"> </div>
<br>
<li> August 2013: Releases sketch and concept of the Hyperloop </li>
<br>
<div class="divider"> </div>
</ul> <!-- END of list -->
<div class="filler"> </div>
</div> <!-- END Body Text -->
<!-- Footer -->
<div id="footer">
<div style="width:600px; height:4px; background-color:black;margin:0 auto">
</div>
<div class="filler"> </div>
<!-- Credits START -->
<h4> <b><em> Credits </em><b> </h4>
<div style="border:1px solid lightgrey;width:550px; margin:0 auto">
<p style="font-size:14px;margin-left:auto; margin-right:auto;color:grey;"> Note this events are not updated to current times. All timeline facts are from </p> <a style="font-size:12px;" class="link" href="http://www.mercurynews.com/2014/04/10/timeline-elon-musks-accomplishments/"> http://www.mercurynews.com/2014/04/10/timeline-elon-musks-accomplishments/ </a>
</div>
<p style="font-size:10px;text-align:center"> <u> Page made by Jacob Bruce </u> </p>
This centers everything BUT the middle text, any solutions?
Add text-align: center; to your <li> tags.
li {
text-align:center;
}
For body text I have added
#body-text ul > li {
text-align:center;
}
Hope this will help You.
Attached snippet.
Let me know if any other issue .
body {
margin:10px;
background-color:white;
}
/* Unordered List */
ul {
border:1px solid green;
width:750px;
}
/* Lists styles */
li {
font-weight:bold;
}
.test-div {
width:500px;
height:250px;
background-color:#f2f2f2;
display:block;
margin-left:auto;
margin-right:auto;
}
#body-text {
width:500px;
display:block;
margin-right:auto;
margin-left:auto;
}
#body-text ul > li {
text-align:center;
}
/* Divider is 1.5 times shorter than header - 750/1.5 = 500 */
.divider {
background-color:black;
width:500px;
height:1px;
}
.text-center {
display:block;
margin-right:0px auto;
margin-left:0px auto;
}
.centered {
display:block;
margin-right:auto;
margin-left:auto;
text-align:center;
}
.link {
text-decoration:none;
margin-left::auto;
margin-right:auto;
}
.link:hover {
text-decoration:none;
color:#00008B;
}
#footer {
text-align:center;
width:800px;
height:500px;
padding:25px;
border:2px solid green;
margin:0 auto;
}
.filler {
height:100px;
}
ul .divider {
margin-right:auto;
margin-left:auto;
}
<head>
</head>
<script>
</script>
<div class="text-center" style="display:block;margin-left:auto;margin-right:auto;background-color:#f2f2f2;width:750px;height:450px;border-radius:15px;">
<img src="https://blog.adioma.com/wp-content/uploads/2016/02/how-elon-musk-started-infographic-700x466.png" alt="Elon Musk Wealth Sahre Joke" style="width:480px;height:380px;margin-left:10; margin-top:20px;"/>
<br>
<em style="font-size:11px;"> Elon musk wealth Share - Joke </em>
</div>
<div id="body-text">
<ul class="text-center" style="list-style-type:none;">
<br>
<div class="centered" style="width:300px;height:40;border:1px solid black;padding-top:10px;">
<h1 style="font-family:monospace"> <em> A Life of Work </em> </h1>
<p> <u> A Timeline of Elon Musk's Life life </u> </p>
</div>
<br>
<li>June 28, 1971 - Born in South Africa </li>
<br>
<div class="divider"> </div>
<br>
<li> Taught himself how to code at age 12</li>
<br>
<div class="divider"> </div>
<br>
<li> Creates and writes a video game called Blastar; sells it for the equivalent of $500 </li>
<br>
<div class="divider"> </div>
<br>
<li> 1988: Graduates from Pretoria Boys High School with distinctions in science and computer studies </li>
<br>
<div class="divider"> </div>
<br>
<li>1989 to 1991: Attends college at Queen’s University in Kingston, Ontario. Then transfers to the University of Pennsylvania; completed a BS in Economics (Wharton) and a BA with a major in physics </li>
<br>
<div class=divider> </div>
<br>
<li> 1995: Moves to Silicon Valley; defers graduate program in applied physics and materials science at Stanford University to join the Internet boom </li>
<br>
<div class="divider"> </div>
<br>
<li> February 1999: Sells Zip2 to Compaq, the personal computer company, for $307 million, of which $22 million went to Musk. Then forms X.com, which in 2000 morphs into PayPal </li>
<br>
<div class="divider"> </div>
<br>
<li> July 2002: eBay acquires PayPal for $1.5 billion in stock, of which $165 million goes to Musk </li>
<br>
<div class="divider"> </div>
<br>
<li> 2002: Becomes an American citizen </li>
<br>
<div class="divider"> </div>
<br>
<li> 2002: Founds SpaceX9 </li>
<br>
<div class="divider"> </div>
<br>
<li> 2004: Invests in Tesla Motors </li>
<br>
<div class="divider"> </div>
<br>
<li> 2007: SpaceX wins $1.6 billion contract to bring cargo to the International Space Station </li>
<br>
<div class="divider"> </div>
<br>
<li> October 2008: Becomes Tesla’s CEO </li>
<br>
<div class="divider"> </div>
<br>
<li> Jun 29, 2010: Tesla IPO </li>
<br>
<div class="divider"> </div>
<br>
<li> May 2012: SpaceX becomes the first commercial vehicle to deliver a load of supplies to the International Space Station. </li>
<br>
<div class="divider"> </div>
<br>
<li> June 2012: Tesla begins deliveries of the all-electric Model S </li>
<br>
<div class="divider"> </div>
<br>
<li> August 2013: Releases sketch and concept of the Hyperloop </li>
<br>
<div class="divider"> </div>
</ul> <!-- END of list -->
<div class="filler"> </div>
</div> <!-- END Body Text -->
<!-- Footer -->
<div id="footer">
<div style="width:600px; height:4px; background-color:black;margin:0 auto">
</div>
<div class="filler"> </div>
<!-- Credits START -->
<h4> <b><em> Credits </em><b> </h4>
<div style="border:1px solid lightgrey;width:550px; margin:0 auto">
<p style="font-size:14px;margin-left:auto; margin-right:auto;color:grey;"> Note this events are not updated to current times. All timeline facts are from </p> <a style="font-size:12px;" class="link" href="http://www.mercurynews.com/2014/04/10/timeline-elon-musks-accomplishments/"> http://www.mercurynews.com/2014/04/10/timeline-elon-musks-accomplishments/ </a>
</div>
<p style="font-size:10px;text-align:center"> <u> Page made by Jacob Bruce </u> </p>
Change your #body-text width to width: 750px; and remove your .ul width property.
#body-text {
width: 750px;
...
}
.ul {
border:1px solid green;
}
you should use flex css property:
your html will look like this (you now need to remove unused classes from markup):
<div class="container"> <!-- !!!!!!!!!! ADD THIS !!!!!!!!!!! -->
<div class="text-center"> <!-- !!!!!REMOVE INLINE STYLE HERE!!!! -->
<img src="https://blog.adioma.com/wp-content/uploads/2016/02/how-elon-musk-started-infographic-700x466.png" alt="Elon Musk Wealth Sahre Joke" style="width:480px;height:380px;margin-left:10; margin-top:20px"/>
<br>
<em style="font-size:11px;"> Elon musk wealth Share - Joke </em>
</div>
<div id="body-text">
<ul class="text-center" style="list-style-type:none;">
<br>
<div class="centered" style="width:300px;height:40;border:1px solid black;padding-top:10px;">
<h1 style="font-family:monospace"> <em> A Life of Work </em> </h1>
<p> <u> A Timeline of Elon Musk's Life life </u> </p>
</div>
<br>
<li>June 28, 1971 - Born in South Africa </li>
<br>
<div class="divider"> </div>
<br>
<li> Taught himself how to code at age 12</li>
<br>
<div class="divider"> </div>
<br>
<li> Creates and writes a video game called Blastar; sells it for the equivalent of $500 </li>
<br>
<div class="divider"> </div>
<br>
<li> 1988: Graduates from Pretoria Boys High School with distinctions in science and computer studies </li>
<br>
<div class="divider"> </div>
<br>
<li>1989 to 1991: Attends college at Queen’s University in Kingston, Ontario. Then transfers to the University of Pennsylvania; completed a BS in Economics (Wharton) and a BA with a major in physics </li>
<br>
<div class=divider> </div>
<br>
<li> 1995: Moves to Silicon Valley; defers graduate program in applied physics and materials science at Stanford University to join the Internet boom </li>
<br>
<div class="divider"> </div>
<br>
<li> February 1999: Sells Zip2 to Compaq, the personal computer company, for $307 million, of which $22 million went to Musk. Then forms X.com, which in 2000 morphs into PayPal </li>
<br>
<div class="divider"> </div>
<br>
<li> July 2002: eBay acquires PayPal for $1.5 billion in stock, of which $165 million goes to Musk </li>
<br>
<div class="divider"> </div>
<br>
<li> 2002: Becomes an American citizen </li>
<br>
<div class="divider"> </div>
<br>
<li> 2002: Founds SpaceX9 </li>
<br>
<div class="divider"> </div>
<br>
<li> 2004: Invests in Tesla Motors </li>
<br>
<div class="divider"> </div>
<br>
<li> 2007: SpaceX wins $1.6 billion contract to bring cargo to the International Space Station </li>
<br>
<div class="divider"> </div>
<br>
<li> October 2008: Becomes Tesla’s CEO </li>
<br>
<div class="divider"> </div>
<br>
<li> Jun 29, 2010: Tesla IPO </li>
<br>
<div class="divider"> </div>
<br>
<li> May 2012: SpaceX becomes the first commercial vehicle to deliver a load of supplies to the International Space Station. </li>
<br>
<div class="divider"> </div>
<br>
<li> June 2012: Tesla begins deliveries of the all-electric Model S </li>
<br>
<div class="divider"> </div>
<br>
<li> August 2013: Releases sketch and concept of the Hyperloop </li>
<br>
<div class="divider"> </div>
</ul> <!-- END of list -->
<div class="filler"> </div>
</div> <!-- END Body Text -->
<div> <!-- !!!!!!!!!! ADD THIS !!!!!!!!!!! -->
<!-- Footer -->
<div id="footer">
<div style="width:600px; height:4px; background-color:black;margin:0 auto">
</div>
<div class="filler"> </div>
<!-- Credits START -->
<h4> <b><em> Credits </em><b> </h4>
<div style="border:1px solid lightgrey;width:550px; margin:0 auto">
<p style="font-size:14px;margin-left:auto; margin-right:auto;color:grey;"> Note this events are not updated to current times. All timeline facts are from </p> <a style="font-size:12px;" class="link" href="http://www.mercurynews.com/2014/04/10/timeline-elon-musks-accomplishments/"> http://www.mercurynews.com/2014/04/10/timeline-elon-musks-accomplishments/ </a>
</div>
<p style="font-size:10px;text-align:center"> <u> Page made by Jacob Bruce </u> </p>
`
for css:
body {
margin:10px;
background-color:white;
}
/* Unordered List */
ul {
border:1px solid green;
width:750px;
}
/* Lists styles */
li {
font-weight:bold;
}
.test-div {
width:500px;
height:250px;
background-color:#f2f2f2;
display:block;
margin-left:auto;
margin-right:auto;
}
/*#body-text {*/
/* width:500px; */
/* display:block; */
/* margin-right:auto; */
/* margin-left:auto; */
/*}*/
/* Divider is 1.5 times shorter than header - 750/1.5 = 500 */
.divider {
background-color:black;
width:500px;
height:1px;
}
/*.text-center {
display:block;
margin-right:0px auto;
margin-left:0px auto;
}*/
/*.centered {
display:block;
margin-right:auto;
margin-left:auto;
text-align:center;
} */
/* THIS IS FLEX */
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.link {
text-decoration:none;
margin-left::auto;
margin-right:auto;
}
.link:hover {
text-decoration:none;
color:#00008B;
}
#footer {
text-align:center;
width:800px;
height:500px;
padding:25px;
border:2px solid green;
margin:0 auto;
}
.filler {
height:100px;
}
ul .divider {
margin-right:auto;
margin-left:auto;
}
a useful guide to flex: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Centering 2 elements adjacent to each other in CSS/HTML

I have two elements (map + description inside a box). When on a large screen, both elements appear on the same line, which is good. However, they stay on the left of the page and I would like them to sit in the middle.
Here is a fiddle of the below:
.map {
float: left padding: 10px;
width: 410px;
border: 1px solid black;
display: inline-block;
}
.map1 {
float: right padding: 10px;
width: 410px;
border: 1px solid black;
display: inline-block;
}
p {
float: left;
width: 100%;
}
<div class="map">
<iframe src="https://ctrc00.carto.com/builder/e2f49f3c-b793-11e6-9ceb-0ef24382571b/embed" width="100%" height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<p><i>
<u>Map 1: <strong>12,083 listings</strong> (Sept.2016)</i>
</u>
<h4><span style="color: #FFA500;"><strong>Activity:</strong></span></h4>
<br>
<strong>183</strong> estimated nights/year
<br>
<strong>$127</strong> price/night
<br>
<strong>50.2%</strong> estimated occupancy
<br>
<strong>$1920</strong> estimated income/month
<br>
<h4><span style="color: #FFA500;"><strong>Listing per Host:</strong></span></h4>
<br>
<strong>38.2%</strong> multi-listings
<br>
<strong>62.0%</strong> single listings
<br>
<br>
<h4><span style="color: #FFA500;"><strong>Room Type:</strong></span></h4>
<br>
<strong>55.3%</strong> entire homes/apartment
<br>
<strong>42.6%</strong> private rooms
<br>
<strong>2.1%</strong> shared rooms
<br>
</p>
</div>
<p>
<div class="map1">
<iframe src="https://ctrc00.carto.com/builder/221c9570-b794-11e6-ad89-0e8c56e2ffdb/embed" width="100%" height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<p><i><u>Map 2: <strong>15,640 listings</strong> (Sept.2016)</p></i>
</u>
<h4><span style="color: #FFA500;"><span style="color: #FFA500;"><strong>Activity:</strong></span></h4>
<br>
<strong>60</strong> estimated nights/year
<br>
<strong>$196</strong> price/night
<br>
<strong>16.3%</strong> estimated occupancy
<br>
<strong>$759</strong> estimated income/month
<br>
<br>
<h4><span style="color: #FFA500;"><strong>Listing per Host:</strong></span></h4>
<br>
<strong>28.5%</strong> multi-listings
<br>
<strong>71.5%</strong> single listings
<br>
<br>
<h4><span style="color: #FFA500;"><strong>Room Type:</strong></span></h4>
<br>
<strong>60.3%</strong> entire homes/apartment
<br>
<strong>37.9%</strong> private rooms
<br>
<strong>1.8%</strong> shared rooms
<br>
</p>
</div>
Above and under, I have some simple text/paragraph that are in the middle.
Just place your whole html code inside this
<div class="container"> </div>
and add one class only
.container{
display: flex;justify-content: center;width:100%;
}
.container {
justify-content: center;
display: flex;
}
<div class="container">
<p class="map_airbnb"><iframe src="https://prox.carto.com/builder/4dedf917-eb0c-4121-8c6d-f4ab2a6b75d3/embed" width="100%" height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<strong>Activity:</strong><br><br>
183 estimated nights/year<br>
$127 price/night<br>
50.2% estimated occupancy<br>
$1920 estimated income/month<br><br>
<strong>Listing per Host:</strong><br>
38.2% multi-listings<br>
62.0% single listings <br><br>
<strong>Room Type:</strong><br>
55.3% entire homes/apartment<br>
42.6% private rooms <br>
2.1% shared rooms <br>
</p>
<p class="map_airbnb1"><iframe src="https://prox.carto.com/builder/4dedf917-eb0c-4121-8c6d-f4ab2a6b75d3/embed" width="100%" height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<strong>Activity:</strong><br><br>
60 estimated nights/year<br>
$196 price/night<br>
16.3% estimated occupancy<br>
$759 estimated income/month<br><br>
<strong>Listing per Host:</strong><br>
28.5% multi-listings<br>
71.5% single listings <br><br>
<strong>Room Type:</strong><br>
60.3% entire homes/apartment<br>
37.9% private rooms <br>
1.8% shared rooms <br>
</p>
</div>
Put an external div or container to your maps and use justify-content:center
Use CSS Flexbox. Wrap these maps inside a container (in my case map_holder).
Have a look at the snippet below (Use full screen):
.map_holder {
display: flex;
justify-content: center;
}
body {
margin: 0;
}
<div class="map_holder">
<p class="map_airbnb"><iframe src="https://prox.carto.com/builder/4dedf917-eb0c-4121-8c6d-f4ab2a6b75d3/embed" width="100%" height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<strong>Activity:</strong><br><br>
183 estimated nights/year<br>
$127 price/night<br>
50.2% estimated occupancy<br>
$1920 estimated income/month<br><br>
<strong>Listing per Host:</strong><br>
38.2% multi-listings<br>
62.0% single listings <br><br>
<strong>Room Type:</strong><br>
55.3% entire homes/apartment<br>
42.6% private rooms <br>
2.1% shared rooms <br>
</p>
<p class="map_airbnb1"><iframe src="https://prox.carto.com/builder/4dedf917-eb0c-4121-8c6d-f4ab2a6b75d3/embed" width="100%" height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<strong>Activity:</strong><br><br>
60 estimated nights/year<br>
$196 price/night<br>
16.3% estimated occupancy<br>
$759 estimated income/month<br><br>
<strong>Listing per Host:</strong><br>
28.5% multi-listings<br>
71.5% single listings <br><br>
<strong>Room Type:</strong><br>
60.3% entire homes/apartment<br>
37.9% private rooms <br>
1.8% shared rooms <br>
</p>
</div>
Hope this helps!
You can use media queries for that, so just update your css like this:
.map_airbnb {
float:left;
width: 50%;
}
.map_airbnb1 {
float:right;
width: 50%;
}
#media screen and (max-width: 480px) {
.map_airbnb,
.map_airbnb1 {
width: 100%;
}
}
Here your original with this update https://jsfiddle.net/9ssukjg4/
Wrap both blocks in a div and use css3 flexbox. Fiddle. – Muhammad Usman 3 mins ago

Can't get these to line up side by side

I can't get these to move to the center of the page. Anyone see what's wrong?
<ul id="contact">
<h1> Contact </h1>
<p> Dreamstowheels#yahoo.com </p>
<p> 2236 El Camino Real <br>
Santa Clara Ca 95050 </p>
</ul>
<ul id="follow">
<h1> Follow </h1>
<img src="http://www.flagera.eu/sites/all/modules/socialmedia/icons/levelten/glossy/32x32/facebook.png">
</ul>
<ul id="supporters">
<h1> Supporters </h1>
<p> Cyclinginquisition.com </p>
<p> Colombia Cycling Team </p>
<p> Calmar Bicycles </p>
<p> Rock Solid Cycling </p>
<p> Fast Freddie Foundation </p>
<p> Golden Creek Services (Envio de Paquetes) </p>
</ul>
</footer>
CSS
footer{ /*Footer section attributes */
margin: -50px auto;
width: 100%;
text-align: center;
/* border-top: solid 1px;*/
}
Let me know if you need to css for the contact, follow, and supporters divs. Thanks in advance.
Erase everything in your CSS code in fiddle and just put the following there.
footer{ margin:0 auto; text-align:center;}
https://jsfiddle.net/u2Zb2/45/