0

I need to adjust my image to a nav bar, but i can't seem to resize or "move" the picture. What is wrong? (The image need to be in center, and be resized to fit the nav bar width)

.forsidebillede {
width: 1000px;
height: 100px;
display: block;
    margin-left: auto;
    margin-right: auto
}
<section class="forsidebillede">
<img src="https://a2ua.com/grey/grey-002.jpg" alt="smoothies"/>
</section>
Andrew Bone
  • 7,092
  • 2
  • 18
  • 33
Munksgaard
  • 25
  • 1
  • 6

3 Answers3

1

There's no code here actually referencing the image.

The below would do this.

.forsidebillede {
width: 1000px;
height: 100px;
display: block;
    margin-left: auto;
    margin-right: auto
}

.forsidebillede > img {
    width:100%;
    height:100%; /* Only if you want the height to be filled also */
    display:block; /* To remove any extra spacing */
}
<section class="forsidebillede">
<img src="smoothie.jpg" alt="smoothies"/>
</section>
0

Not sure what you mean by resize to fit navbar. But centering can be simple.

.forsidebillede {
  width: 1000px;
  height: 100px;
  display: block;
  margin:0 auto;
  text-align:center;
}
<section class="forsidebillede">
<img src="http://www.jambajuice.com/~/media/www/images/products/product/smoothies/almond-milk-smoothies-promotion/Almond%20Milk%20smoothies%20category%20image.ashx" alt="smoothies"/>
</section>

I am completely guessing but are you truying to resize the image to fits its container? Like this?

.forsidebillede {
  width: 1000px;
  height: 100px;
  display: block;
  margin:0 auto;
  text-align:center;
}
.forsidebillede img{
  height:100%; 
  width:100%;
}
<section class="forsidebillede">
<img src="http://www.jambajuice.com/~/media/www/images/products/product/smoothies/almond-milk-smoothies-promotion/Almond%20Milk%20smoothies%20category%20image.ashx" alt="smoothies"/>
</section>
DreamTeK
  • 32,537
  • 27
  • 112
  • 171
0

Hello just add this extra Css in your style

  .forsidebillede img{
   width:100%;
   height:100%;
   }
Asifuzzaman Redoy
  • 1,773
  • 1
  • 15
  • 30