How can I remove strange gap between image and border on html page

53 views Asked by At

in the articles section of a html page im working on there is a small gap between the images and the border.

Here is the HTML

 <article>
     <section class="image">
         <a href=""><img src="images/Thumbnail.gif" height="150" width="150" alt=""/></a>
     </section>
     <aside class="textBox">
         <h3>Project</h3>
         <p>description</p>
     </aside>
 </article>

And here is the CSS (there is some redundant parts i'm removing them at the moment)

@charset "UTF-8";
body {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  background-color: #64748B;
  padding: 4em;
  color: #000;
  background-image: url("images/background.png");
  background-repeat: no-repeat;
  background-position: top absolute;
  background-size: cover;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap
}
H1 {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  color: #fff;
  float: right;
  margin-right: 1em;
  font-size: 40pt;
}
.NavUl {
  margin-top: 5px;
  font-weight: bold;
  text-align: center;
  width: 100%;
}
td {
  background-color: #000;
  border: 5px outset;
  border-color: #22222B
}
.textBox {
  height: 150px;
  color: #ffffff;
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  padding-left: 1em;
}
header {
  background-color: #090B16;
  width: 100%;
  border: 6px outset #22222B;
}
article {
  margin-top: 5px;
  margin-bottom: 5px;
  display: flex;
  background-color: #090B16;
  border: 6px outset #22222B;
  padding: 0
}
a:link, a:visited {
  text-decoration: none;
  color: #fff;
}
.logo {
  padding: 1em;
}
p {
  font-size: 12pt;
}
.image {
  padding: 0;
  margin: 0;
  border: 6px inset #7079B1
}
.post {
  width: 100%;
    
}

I don't know if this makes a difference but im using adobe dream weaver (which I hate, VSC superiority)

Ive tried messing with the padding and margins as well as the height, alas none of these things has made a difference.

2

There are 2 answers

0
lineal On BEST ANSWER

I added height:150px to your .image CSS, it seems to have removed the space at the bottom.

@charset "UTF-8";
body {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  background-color: #64748B;
  padding: 4em;
  color: #000;
  background-image: url("images/background.png");
  background-repeat: no-repeat;
  background-position: top absolute;
  background-size: cover;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap
}
H1 {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  color: #fff;
  float: right;
  margin-right: 1em;
  font-size: 40pt;
}
.NavUl {
  margin-top: 5px;
  font-weight: bold;
  text-align: center;
  width: 100%;
}
td {
  background-color: #000;
  border: 5px outset;
  border-color: #22222B
}
.textBox {
  height: 150px;
  color: #ffffff;
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  padding-left: 1em;
}
header {
  background-color: #090B16;
  width: 100%;
  border: 6px outset #22222B;
}
article {
  margin-top: 5px;
  margin-bottom: 5px;
  display: flex;
  background-color: #090B16;
  border: 6px outset #22222B;
  padding: 0
}
a:link, a:visited {
  text-decoration: none;
  color: #fff;
}
.logo {
  padding: 1em;
}
p {
  font-size: 12pt;
}
.image {
  height: 150px;
  padding: 0;
  margin: 0;
  border: 6px inset #7079B1
}
.post {
  width: 100%;
    
}
 <article>
     <section class="image">
         <a href=""><img src="https://placehold.jp/150x150.png" height="150" width="150" alt=""/></a>
     </section>
     <aside class="textBox">
         <h3>Project</h3>
         <p>description</p>
     </aside>
 </article>

1
samran feli On

img default display is inline and its default vertical-align I think is baseline. I think it causes this behavier. you also can set its vertical-align top or bottom or middle to omit this gap.

add this css:

.image img {
  display:block
}

or:

.image img {
  vertical-align:top;
}

or:

.image img {
  vertical-align:bottom;
}

or:

.image img {
  vertical-align:middle;
}