Newbie question: I'm trying to put a photo on the right side of a website, have the text wrap around on the left, and have a photographer credit directly under the photo.
The credit is showing up on the left side above the text header instead of under the photo on the right.
Here's my html:
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'/>
<link rel='stylesheet' href='test.css'/>
</head>
<body>
<picture>
<img class='pic' src='images\str_pic1.JPG' alt="Person in blue shirt" />
<figcaption class='pic'>Photo Credit: Photographer</figcaption>
</picture>
<div>
<h2>Title</h2>
<p>Text text text etc. this is the text body</p>
</div>
</body>
</html>
Here's my CSS:
.page {
font-size: 100%;
background-color: #777;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.pic {
width: 35%;
float: right;
margin-left: 20px;
}
I tried putting the pic and credit in a div box & using:
.pic-box {
display: flex;
flex-direction: column;
}
in the CSS. This did not work.
First time asking a question here, please let me know if I can improve!
I believe this is what you want. I replaced your
<picture>
andfigcaption
withdiv
. Divs are very easy to work with. I then gave the wrapping div (which was formerly<picture>
the class ofpicwrap
and then the formerfigcaption
div a class ofpiccap
simply to make it not the same class as the picture which ispic
.I then added this to your CSS:
Here's a working example with a picture I added as well as gave it mroe text so you can see the wrapping.