February 28, 2012

Background smaller than containing div (of variable size)

Question by danapaige

I want to create a slightly indented background behind embedded media, for which the size varies. It should look like this:

what it should look like

See how the green background is slightly indented from the top and bottom of the youtube video? I have gotten everything else to show up as I want, I just can’t figure out how to position the background slightly inside of the embedded media item. Especially since I know the media item size will change.

You can see what I have so far on JSfiddle.

Answer by Starx

Simple give negative margin like

iframe { margin-top: -10px; }

DEMO

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!