0

I planed to add an image below a div. It would be below a navigation bar (div), adding some nice shadow effect (img). Looks like this:

<div>...</div>
<img>

So far it is just in the html code, but I want to keep the html code since it's a theme that gets updated frequently. So I want to alter only the CSS.

Is there a way to do that without altering HTML code, just using CSS?

1
  • can you give demo in jsfiddle.net Commented Dec 20, 2012 at 11:55

2 Answers 2

1

Two suggestions:

  1. Add the shadow image as a 1px x Xpx repeating background image to the bottom of your nav DIV. So it would sit within the nav DIV. Simply add some padding to the bottom of the NAV DIV to accomodate it e.g.

nav { padding-bottom:6px; background:url(images/nav-bg.png) repeat-x 0 bottom; }

(The above code would presume you have a background image which is 6px in height and probably 1px wide (but that's up to you) and the path would obviously have to be adjusted to be where your actual image was located.

  1. Instead of adding an IMAGE under the NAV DIV add another DIV and once again add a 1px x Xpx shadow image to that DIV through the CSS.
Sign up to request clarification or add additional context in comments.

2 Comments

@MyrkoThum - I've added some code into my answer above for you.
Cool, glad to help, please upvote my answer and accept it when you're able to.
1

you cant change the source of an image element through css... you could create the shadow using CSS tho:

    -webkit-box-shadow: 0 8px 6px -6px black;
   -moz-box-shadow: 0 8px 6px -6px black;
        box-shadow: 0 8px 6px -6px black;

or you could change the image through javascript or from the codehind

javascript: $(element).src = "path to new image";

2 Comments

Thanks, but there was a small misunderstanding there: right now there is no image in the html code. I put it there temporarily but want to remove it eventually, adding a NEW image via CSS below the div. Is that doable?
no CSS is "cascading style sheet" you cant add html elements. javascript or codebehind is the way to go if you want to add an element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.