Unwanted white space between image and border

Asked

Viewed 290 times

1

Every time I put the edge it gets this problem, the funny thing is q this working well in other projects (I tried to put the edge straight in the figure.photo-caption img, it worked but to create the effects got pretty messed up and before it was like this. inserir a descrição da imagem aqui

<!DOCTYPE html>
<html lang="pt-br">
	<head>
		<meta charset="utf-8">
		<title> Testando </title>

		<style>

		figure.foto-legenda {
			border: 3px solid black;
			position: relative;

 		}

		figure.foto-legenda img {
			width: 100%;
			height: 100%;
		}

		figure.foto-legenda figcaption {
			position: absolute;
			top: 0px
		}

		</style>
	</head>
	<body>

	<h1>The Simpsons</h1>
		<figure class="foto-legenda">
			<img src="imagens/homer.jpg"/>
				<figcaption>
					<h1> Homer Simpson </h1>
				</figcaption>
		</figure>
	</body>
</html>

  • Does the image itself not have this white space? Dai it is better to remove cutting with some image editor

  • No and I have tested with several images.

2 answers

0

An alternative solution to your problem is to add width and height in figure.photo-caption:

inserir a descrição da imagem aqui

<!DOCTYPE html>
<html lang="pt-br">
	<head>
		<meta charset="utf-8">
		<title> Testando </title>

		<style>

		figure.foto-legenda {
			border: 3px solid black;
			position: relative;
                        width: 800px;
                        height: 600px;

 		}

		figure.foto-legenda img {
			width: 100%;
			height: 100%;
		}

		figure.foto-legenda figcaption {
			position: absolute;
			top: 0px
		}

		</style>
	</head>
	<body>

	<h1>The Simpsons</h1>
		<figure class="foto-legenda">
			<img src="https://www.tricurioso.com/wp-content/uploads/2019/01/fatos-curiosos-sobre-o-homer-simpson-667x400.jpg"/>
				<figcaption>
					<h1> Homer Simpson </h1>
				</figcaption>
		</figure>
	</body>
</html>

-1

try this here

<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <meta charset="utf-8">
        <title> Testando </title>

        <style>

        figure.foto-legenda {
            border: 3px solid black;
            position: relative;
            display: flex;
        }

        figure.foto-legenda img {
            width: 100%;
            height: 100%;
        }

        figure.foto-legenda figcaption {
            position: absolute;
            top: 0px
        }

        </style>
    </head>
    <body>

    <h1>The Simpsons</h1>
        <figure class="foto-legenda">
            <img src="https://cdn-ofuxico.akamaized.net/img/upload/noticias/2018/08/22/what-homer-simpson-taught-us-about-doughnuts_327781_36.jpg"/>
                <figcaption>
                    <h1> Homer Simpson </h1>
                </figcaption>
        </figure>
    </body>
</html>
  • For you to see that madness, I made the code again the same way and it worked. My code worked for you?

  • kkkkkkk normal, sometimes if we really pass, the tiredness kkkkk, but then add the display, so it doesn’t happen again. kkk

  • But what this display does?

  • the display specifies the display behavior (the rendering box type) of an element.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.