html - Text over top of image scrolling left and right -
i trying create rollover effect image css. image starts title overlaid, when hovered on text overlay appears. happy how going far, except text area comes on top text runs off right. can scroll , down, assuming same problem?
https://jsfiddle.net/p27sf4e1/3/
html
<div class="service-box"> <p class="box-title">social media</p> <div class="service-overbox"> <h2 class="title">social media</h2> <p class="tagline">lorem ipsum dolor sit amet, consectetur adipiscing elit. integer ac sodales lorem. donec condimentum feugiat feugiat. vestibulum blandit dolor risus, eget fringilla sem suscipit vel. in id ex ut nulla mollis suscipit nec in velit. fusce auctor dapibus elit. nam in justo sapien.</p> </div> </div>
css
.service-box .overtext { -webkit-transition: 300ms ease-out; -moz-transition: 300ms ease-out; -o-transition: 300ms ease-out; -ms-transition: 300ms ease-out; transition: 300ms ease-out; transform: translatey(40px); -webkit-transform: translatey(40px); } .service-box .title { text-align: center; opacity: 0; transition-delay: 0.1s; transition-duration: 0.2s; } .service-box:hover .title, .service-box:focus .title { opacity: 1; transform: translatey(0px); -webkit-transform: translatey(0px); } .service-box .tagline { text-align: center; opacity: 0; transition-delay: 0.2s; transition-duration: 0.2s; } .service-box:hover .tagline, .service-box:focus .tagline { opacity: 1; transform: translatex(0px); -webkit-transform: translatex(0px); } .service-overbox { background-color: #000000; position: relative; color: #fff; z-index: 2; -webkit-transition: 300ms ease-out; -moz-transition: 300ms ease-out; -o-transition: 300ms ease-out; -ms-transition: 300ms ease-out; transition: 300ms ease-out; opacity: 0; width: 100%; height: 100%; padding: 30px; } .service-box:hover .service-overbox { opacity: 0.7; } .service-box:hover .box-title { opacity: 0; } .service-box { cursor: pointer; position: relative; overflow: auto; height: 380px; width: 100%; max-width: 580px!important; background-image: url(http://www.voicecommunications.co.uk/voice-website-new/wp-content/uploads/2016/07/voice-social-media.jpg); background-size: cover; background-repeat: no-repeat; } .box-title { position: absolute; top: 40%; left: 50%; margin-right: -50%; transform: translate(-50%, -50%); color: #ffffff; font-size: 38px; line-height: 38px; font-family: 'anton', sans-serif; color: #00aac4; } .tagline { font-family: 'source sans pro', sans-serif; font-weight: 300; line-height: 28px; } .title { font-size: 40px!important; font-family: 'anton', sans-serif; font-weight: 600; margin-bottom: 10px; }
appreciate comments may solve.
thanks
if you're not supporting ie7 , lower, try adding box-sizing: border-box;
property .service-overbox
rule. looks it's legacy box-model's handling of padding
tripping up.
.service-box .overtext { -webkit-transition: 300ms ease-out; -moz-transition: 300ms ease-out; -o-transition: 300ms ease-out; -ms-transition: 300ms ease-out; transition: 300ms ease-out; transform: translatey(40px); -webkit-transform: translatey(40px); } .service-box .title { text-align: center; opacity: 0; transition-delay: 0.1s; transition-duration: 0.2s; } .service-box:hover .title, .service-box:focus .title { opacity: 1; transform: translatey(0px); -webkit-transform: translatey(0px); } .service-box .tagline { text-align: center; opacity: 0; transition-delay: 0.2s; transition-duration: 0.2s; } .service-box:hover .tagline, .service-box:focus .tagline { opacity: 1; transform: translatex(0px); -webkit-transform: translatex(0px); } .service-overbox { background-color: #000000; position: relative; color: #fff; z-index: 2; -webkit-transition: 300ms ease-out; -moz-transition: 300ms ease-out; -o-transition: 300ms ease-out; -ms-transition: 300ms ease-out; transition: 300ms ease-out; opacity: 0; width: 100%; height: 100%; padding: 30px; box-sizing: border-box; } .service-box:hover .service-overbox { opacity: 0.7; } .service-box:hover .box-title { opacity: 0; } .service-box { cursor: pointer; position: relative; overflow: auto; height: 380px; width: 100%; max-width: 580px!important; background-image: url(http://www.voicecommunications.co.uk/voice-website-new/wp-content/uploads/2016/07/voice-social-media.jpg); background-size: cover; background-repeat: no-repeat; } .box-title { position: absolute; top: 40%; left: 50%; margin-right: -50%; transform: translate(-50%, -50%); color: #ffffff; font-size: 38px; line-height: 38px; font-family: 'anton', sans-serif; color: blue; } .tagline { font-family: 'source sans pro', sans-serif; font-weight: 300; line-height: 28px; } .title { font-size: 40px!important; font-family: 'anton', sans-serif; font-weight: 600; margin-bottom: 10px; }
<div class="service-box"> <p class="box-title">social media</p> <div class="service-overbox"> <h2 class="title">social media</h2> <p class="tagline">lorem ipsum dolor sit amet, consectetur adipiscing elit. integer ac sodales lorem. donec condimentum feugiat feugiat. vestibulum blandit dolor risus, eget fringilla sem suscipit vel. in id ex ut nulla mollis suscipit nec in velit. fusce auctor dapibus elit. nam in justo sapien.</p> </div> </div>
Comments
Post a Comment