hover - Move location of text in a box in html -
trying implement hover on caption on image opaque overlay appears words having bit of trouble.
my code below:
<style type="text/css"> a.hovertext { position: relative; width: 220px; text-decoration: none !important; text-align: center; } a.hovertext:after { content: attr(data-title); position: absolute; left: 0; bottom: 5px; padding: 0em 0px; width: 220px; height: 220px; background: rgba(0,0,0,0.8); text-decoration: none !important; color: #fff; opacity: 0; -webkit-transition: 0.5s; -moz-transition: 0.5s; -o-transition: 0.5s; -ms-transition: 0.5s; } a.hovertext:hover:after, a.hovertext:focus:after { opacity: 1.0; } </style> <a class="hovertext" data-title="europe 2014" href="url"><img alt="" border="0" src="url" height="220" width="220" /></a>
the idea how want can't figure out how move text middle of box vertically it's centered , how change size , style of font.
any ideas? i'm sure it's easy modification i'm not @ html.
instead of using line-height
, can use achieve goal:
display: -webkit-box; /* old: safari, ios, android browser, older webkit browsers. */ display: -moz-box; /* old: firefox (buggy) */ display: -ms-flexbox; /* mid: ie 10 */ display: -webkit-flex; /* new, chrome 21–28, safari 6.1+ */ display: flex; /* new: ie11, chrome 29+, opera 12.1+, firefox 22+ */ -webkit-box-align: center; -moz-box-align: center; -ms-flex-align: center; -webkit-align-items: center; justify-content: center; /* align horizontal */ align-items: center; /* align vertical */
updated font-size
, font-family
: http://jsfiddle.net/q6jlx/2/ (updated have compatibility ie10 -ms-flexbox
)
i have added this:
a.hovertext:after { ....... font-size: 30px; font-family: 'montserrat', sans-serif; ....... }
and imported google font: <link href='http://fonts.googleapis.com/css?family=montserrat' rel='stylesheet' type='text/css'>
my hint download font need , use it.
----------- method without flex
, line-height
------------
i not know if using plugin or coding yourself, if data-title
not mandatory, here method: http://jsfiddle.net/q6jlx/3/
display: table-cell
compatibility: http://www.browsersupport.net/css/display:table-cell
Comments
Post a Comment