0
I know that to align a text you use the text-align: center
.
But to align a photo that has a link in it? I did some tests here with some commands that I n know like the align-content
, to see if it worked, but it didn’t. I have two questions.
1° How to align a photo that has a link in the center of the page?
2° Is this line right? To later put the alignment code inside it.
.imagem {}
Edit: I tried to put the margin:auto
, in div
image, but n worked, n made some change.
Html:
<!DOCTYPE html>
<html>
<head>
<title>sas</title>
<link rel="stylesheet" type="text/css" href="sasi.css">
</head>
<body>
<div class="imagem">
<a href="#"><img src="https://lh3.googleusercontent.com/l6JAkhvfxbP61_FWN92j4ulDMXJNH3HT1DR6xrE7MtwW-2AxpZl_WLnBzTpWhCuYkbHihgBQ=w640-h400-e365" width="50%" height="50%"></a>
</div>
</body>
</html>
Css:
.imagem {
margin:auto; //aplica margem aos quatro lados
width:200px;
}
If the div does not have a set size it will be 100% of the page vertically or 100% of the other div, but since you did not present the full code it is not possible to know what is causing the problem
– Mark Vaaz
@Markvaaz I put your code in that file, it really didn’t work the margin: center. I changed the image size from 100% to 50%, because 100% of the image was the screen size, and I could not tell if the code to center in the middle of the page would have worked.
– jim
@Markvaaz Exactly.
– jim
sasi
is the css file? wouldn’t it besasi.css
? and there is no margin center, to center horizontally usemargin:auto;
ormargin:10px auto;
10px to set 10px margin vertically, do not need to be necessarily 10px, you can set the amount you prefer– Mark Vaaz
@Markvaaz Yes, I forgot to put the .css. I put agr, but n changed anything. It is the right is margin: self, as you said, I only got confused at the time I wrote the comment. This code I pasted there, you tested to see if it centered in the middle?
– jim
I changed the answer and put your
HTML
– Mark Vaaz