css - moving text over an image, without the image moving -


i have banner trying add text bottom portion of it. got text centered , how want be, when want move text bottom of page, picture moves too.

html

<div class="col_one art-banner">         <div class="art-banner-text">             <h2>what <span>you</span> want learn?</h2>         </div> </div> 

css

.art-banner { background-image: url("graphics/art_banner.jpg"); height: 150px;} .art-banner-text { width: 940px; height: 50px; background-color: rgba(0,0,0,0.5); } .art-banner-text h2 { text-align: center; padding-top: 10px; font-family: "bender";} .art-banner-text span { color: #eb6623; } 

jsfiddle

presuming you're trying use margin-top move art-banner-text down, you're running collapsing margin problem: margin shared between inner div , outer one, meaning outer 1 gets margin too.

so solution not use margins, position:relative outer div , position:absolute inner one, bottom:0 position @ bottom of outer one.

.art-banner {    background-image: url("https://photos-2.dropbox.com/t/2/aaats4uxanyf0x4vh0ty5le779vffs2smjuwyjfsfwnmpg/12/18401260/jpeg/32x32/1/1437685200/0/2/art_banner.jpg/coyp4wggasaciamgbcafiaygbygbkaiobw/l9jvtmzn-g-n3cmbdujkzkxxzuwr9ntwvteoblnl_4g?size=1024x768&size_mode=2");    height: 150px;    position: relative;  }  .art-banner-text {    width: 940px;    height: 50px;    background-color: rgba(0, 0, 0, 0.5);    position: absolute;    bottom: 0;  }  .art-banner-text h2 {    text-align: center;    padding-top: 10px;    font-family: "bender";    margin: 0;  }  .art-banner-text span {    color: #eb6623;  }
<div class="col_one art-banner">    <div class="art-banner-text">      <h2>what <span>you</span> want learn?</h2>    </div>  </div>

(note had change uri image, make show up. had uri dropbox page displays image, not image itself.)


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -