Im trying to align my image that is defined in a div statement next to a list.
body { background-color: #3799DF;
color:#1B78BB;
font-family: Arial;
margin: 0; }
* { box-sizing: border-box; }
header { background-color: #3799DF;
background-image: url(FullLogoBanner.png);
background-position: left;
background-repeat: no-repeat;
font-size: 105%;
max-height: 250px; }
header a { text-decoration: none; }
header a:link { color: #40407A }
header a:visited { color: #40407A }
header a:hover { color: #FFF }
h1 { padding-top: 80px;
padding-left: 6em; }
nav { font-weight: bold;
text-align: center;
position: relative;
padding-bottom: 1.5em; }
nav a { text-decoration: none;
display: block;
border-width: 2px;
border-style: groove;
border-color: #1B78BB;
padding: 0.7em;
background-color: #8ADFFF;
margin-left: 0.5em;
margin-right: 0.5em; }
nav a:link { color: #000000; }
nav a:visited { color: #40407A; }
nav a:hover { color: #3799DF; border: 2px groove #333333; }
nav ul { list-style-type: none;
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin: 0; }
nav ul ul { position: absolute;
background-color: #FFF;
padding: 0;
text-align: center;
display: none; }
nav ul ul li { display: block;
border-width: 2px;
border-style: groove;
border-color: #8ADFFF;
padding: 0.5em;
background-color: #FFF;
width: 8em; }
nav li:hover ul { display: block; }
main { padding-left: 2em;
padding-right: 2em;
display: block; }
section {padding-left: .5em;
padding-right: .5em; }
footer { font-size: .70em;
font-style: italic;
text-align: center;
color: #000000;
padding: 1em;
background-color: #8ADFFF; }
.name { font-weight: bold; }
.home { height: 40vh;
padding-top: 2em;
padding-left: 10%; }
.content { height: 40vh;
padding-top: 2em;
padding-left: 10%; }
#mobile { display: inline; }
#desktop { display: none; }
#wrapper { background-color: #F5F5F5;
padding: 2em; }
#homeimg { background-image: url(petstore_dog.jpg);
background-repeat: no-repeat;
height: 300px;
background-size: contain;
display: none; }
.header { text-decoration: underline; }
#column { display: flex;
flex-direction: column;
align-items: center; }
#center { text-align: center;
padding-left: 1.5em;
margin: auto; }
#left { text-align: left;
padding: 1em;
margin: auto; }
table { width: 100%;
margin: auto;
border: 1px solid #3799DF;
border-collapse: collapse;
margin-bottom: 1em; }
td, th { padding: 1px;
border: 1px solid #3799DF;
text-align: center; }
tr:nth-of-type(odd) { background-color: #89CFF0; }
caption { margin: 1em;
font-weight: bold;
font-size: 120%; }
form { display: flex;
flex-direction: column;
padding-left: 1em;
width: 80%; }
input { margin-bottom: .5em; }
@media (min-width: 645px) {
header { background-color: #3799DF;
background: url(LogoDesign2.png) no-repeat left,
url(Pawprints.png) repeat-x bottom,
url(Pawprints.png) repeat-x;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
font-size: 150%;
max-height: 355px; }
.home { height: 50vh; }
.content { height: 50vh; }
nav ul { display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center; }
section { padding-left: 2em;
padding-right: 2em; }
#homeimg { display: block; }
#flow { display: flex;
flex-direction: row; }
form { display: grid;
grid-gap: 1em;
grid-template-columns: 12em 1fr;
width: 60%; }
input[type="submit"] { grid-column: 2 / 3;
width: 9em; }
label { float: right; }
#mobile { display: none; }
#desktop { display: inline; }
table { width: 80%; }
@media (min-width: 1045px) {
header { background: url(LogoDesign1.png) no-repeat left,
url(LogoDesign1.png) no-repeat right,
url(Pawprints.png) repeat-x,
url(Pawprints.png) repeat-x bottom;
font-size: 160%; }
.home { height: 50vh; }
.content { height: 50vh; }
#wrapper {margin: auto;
width: 75%; }
footer { margin: auto;
width: 75%; }
table { width: 65%; } }
Here is my css ^
`<div id="wrapper">
<main>
<h2>Your Local Pet Shop</h2>
<p><span class="name">Furry Baby</span> is the best place to go for all your pet shopping needs
in the Hyde Park area. We provide options for all your favorite furry friends including: Dogs, Cats, and Birds.
<br>Our services have allowed pet owners to thrive with their best friends since 1989. Come to <span class="name">Furry Baby</span>
and let your animal companion live their best life!</p>
<p>We cater towards cat, dog, and bird owners!<br> Currently we sell:</p>
<ul>
<li>Leashes</li>
<li>Collars</li>
<li>Toys</li>
<li>Treats</li>
<li>Cages</li>
<li>And more!</li>
</ul>
<div id="homeimg">
</div>
<span class="name">Furry Baby</span><br>
123 Hyde Park North<br>
Tampa, Florida, 33606<br><br>
<a id="mobile" href="tel:888-555-5555">888-555-5555</a>
<span id="desktop">888-555-5555</span>
</main>`
Here is part of my home page ^
I’ve tried using a flexbox row container to align them and it does not work, I’ve tried setting them both to float left and right, respectively. Ideally, I would want the picture on the left and the list on the right but no matter what I try either the list ends up off the page/unaligned or the image just doesn’t show up if I put it to float.
2
Answers
You can wrap your content in a
.wrapper
class, and apply flexbox to it, and group your two sections into divs. Something like this:so I would start with making sure that I understand css flexbox properly. By this I mean reading those articles:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
And later on I would try to implement flexbox in similar fashion to the snippet below. You are on the right track, just keep on going 🙂