Solution 1 :

There is no display:run-in;. You can use display:block and position: absolute on the image, plus parameters for its position (top/bottom/left/right, also using percentage values), maybe transform (for centering), and size to position it wherever you want, independently of the parent element.

Problem :

I’m currently trying to create a header for a website. My problem is, that I try to scale a img inside my div, but the div element resizes with it.

This is my header

I wish to keep the original size of the div (the green part), while being able to resize my cake img

Here is my current css for the header:

.container-header {
 position:inherit;
 vertical-align: top;
 background: green;
 width: 100%;
 margin-bottom: 300px;

}

.container-header img {
display:run-in;
height: 200px;
}

.container-header a {
display: inline-block;
background: red;
width: 100px;
margin-left: 25px;
margin-right: 25px;
}

.header-logo {
position: relative;
top: 100px;
}

Edit:
Here is my html:

<div class="container-header">

<a href="index.html" style="left: 25%"><p>Koti</p></a>
<a href="leipomot.html"><p>Leipomot</p></a>

<img class="header-logo" src="IMGlogo_placeholder.png" alt="" height="30px">

<a href="index.html"><p>Tuotteet</p></a>
<a href="yhteystiedot.html"><p>Yhteystiedot</p></a>

<a href="PHP/shoppingcart.php"><div class="shoppingcart">
<i class="fa fa-shopping-cart"></i>
</div></a>
</div>

Comments

Comment posted by Nathaniel Flick

Hi can you also post your html please so we can help. I would say if you set a max height then you can use overflow hidden to hide any additional image from showing, or better yet use a background image with background-size: cover and it will always fit without changing the div size.

Comment posted by Paulie_D

How are you trying to “scale the image”?

Comment posted by chriskirknielsen

You can probably set the header to a flex element, and your image container to

Comment posted by developer.mozilla.org/en-US/docs/Web/CSS/display

Actually there IS

Comment posted by Johannes

okay – I am always thinking of real-world websites which work

Comment posted by Antti Veikkolainen

This worked for me, however I think this is kind of a messy way of doing this. I need to manually move most of the elements in order to make way for my image to be in the middle.

Comment posted by Johannes

you could leave the original (small) image as is and

By