I have a problem with creating centered boxes with css. For now I have this:
http://jsfiddle.net/LW7mN/2/
.trex-clear-all{
display: inline-block;
width: 99%;
height: 17px;
font-size: 12px !important;
text-align: -webkit-right !important;
text-align: right;
}
#trex_showonhover{
visibility:hidden;
background-color:#FFFFFF;
border:1px solid #999999;
cursor:default;
position:absolute;
text-align:center;
width: 280px;
z-index:100;
-moz-border-radius: 15px;
border-radius: 15px;
padding: 10px 10px 10px;
}
#trex_close_div{
top:6px;
right:6px;
position:absolute;
}
.trex_showdiv{
width:310px;
float: right;
}
.trex-text-title{
font-family: 'Segoe UI_', 'Open Sans', Verdana, Arial, Helvetica, sans-serif !important;
font-size: 11px !important;
font-weight:700 !important;
padding: 2px !important;
}
.trex-new-widget-container {
font: 10pt normal Arial, sans-serif;
height: auto;
margin: 10px auto 0 auto;
text-align: center;
width: 100%;
}
.trex-new-widget-container .trex-box {
border: 1px solid #000;
cursor: pointer;
height: 180px;
width: 240px;
float: left;
margin: 3px;
position: relative;
overflow: hidden;
-webkit-box-shadow: 2px 1px 1px 1px #ccc;
-moz-box-shadow: 2px 1px 1px 1px #ccc;
box-shadow: 2px 1px 1px 1px #ccc;
}
.trex-new-widget-container .trex-box img {
position: absolute;
left: 0;
width:100%;
height: 100%;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
.trex-new-widget-container .trex-box .trex-caption {
background-color: rgba(240,240,240,0.6);
position: absolute;
color: #000 !important;
z-index: 1000;
-webkit-transition: all 400ms ease-out;
-moz-transition: all 400ms ease-out;
-o-transition: all 400ms ease-out;
-ms-transition: all 400ms ease-out;
transition: all 400ms ease-in;
left: 0;
}
.trex-new-widget-container .trex-box .trex-full-caption {
width: 240px;
height: 50px;
top: 130px;
text-align: center;
padding-top: 0px;
}
.trex-new-widget-container .trex-box:hover .trex-full-caption {
-moz-transform: translateY(-60px);
-o-transform: translateY(-60px);
-webkit-transform: translateY(-60px);
transform: translateY(-60px);
opacity: 1;
background-color: rgba(0,0,0,0.9);
color: #fff !important;
}
As you can see, when you change page width (resize browser, or change resolution) number of boxes per row are changing. That's ok, but the boxes shoud be aligned in the middle, not on the left as it is now.
I hope you understand what is the problem. Here is simple sketch so you can visualize it.
Thanks
.trex-new-widget-container .trex-box {
border: 1px solid #000;
box-shadow: 2px 1px 1px 1px #ccc;
cursor: pointer;
display: inline-block;
/*float: left;*/
height: 180px;
margin: 3px;
overflow: hidden;
position: relative;
width: 240px;
}
Use display instead float :
.trex-new-widget-container .trex-box {
border: 1px solid #000;
box-shadow: 2px 1px 1px 1px #ccc;
cursor: pointer;
display: inline-block;
height: 180px;
margin: 3px;
overflow: hidden;
position: relative;
width: 240px;
}
Related
I'm working on some buttons that fill with a color when you hover over the button. The transition works perfectly on safari that runs on a MacBook. But when I do the animation on my windows device with Chrome, it has a hiccup on the end with multiple flashes. I have searched around for a solution but I couldn't find any.
.button_slide {
color: black;
border: 2px solid #ffffff;
border-radius: 0px;
padding: 18px 45px;
display: inline-block;
font-family: "Lucida Console", Monaco, monospace;
font-size: 14px;
letter-spacing: 5px;
cursor: pointer;
box-shadow: inset 0 0 0 0 #ffffff;
/* -webkit-transition: ease-out 0.4s !important;
-moz-transition: ease-out 0.4s !important; */
transition: ease-out 0.4s;
}
.slide_diagonal:hover {
box-shadow: inset 400px 50px 0 0 #007ACC;
border: 2px solid #007ACC;
}
#outer {
position: relative;
top: 60%;
left: 50%;
transform: translate(-50%,-50%);
width: 364px;
/*margin: 50px auto 0 auto;*/
text-align: center;
}
<div id="outer">
<div class="button_slide slide_diagonal">KLIK HIER</div>
</div>
Reason of hiccup
The answer from DreamTeK helped out to point out the issue. It looks like that when a transform transform: translate(-50%,-50%); is applied to #outer, Chrome will hiccup the animation. The only question that will be left is, why does this cause the issue?
edit: typos, extra information
I wasn't able to pinpoint the exact reason Chrome has issues with the box-transition however I used a differant method that creates the same effect much smoother.
#outer {
width: 220px;
margin: 50px auto;
text-align: center;
}
.button_slide {
position: relative;
color: black;
border: 2px solid #ffffff;
padding: 18px 45px;
display: block;
font: 14px "Lucida Console", Monaco, monospace;
letter-spacing: 5px;
text-decoration: none;
cursor: pointer;
transition: ease-out 0.4s;
width: 100%;
box-sizing: border-box;
}
.button_slide::before {
content: '';
box-shadow: inset 0 0 0 0 #fff;
transition: ease-in-out 0.4s;
border: 2px solid #fff;
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
box-sizing: border-box;
z-index: -1;
}
.slide_diagonal:hover::before {
box-shadow: inset 300px 50px 0 0 #007ACC;
border-color: #007ACC;
}
<div id="outer">
<a class="button_slide slide_diagonal">KLIK HIER</a>
</div>
I was under the impression that if an element has a set height & width of 0, padding wouldn't push the width/height if the box-sizing is also set to border box, the thing is, this does seem to be the case, but as soon as I add a 1px solid border, the padding gets applied.
div#search > form#sform > a { display: inline-block; width: 20%; }
input#q { width: 80%; display: inline-block; border: 0px; }
div#search > form#sform > a { display: inline; width: 20%; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70' style='width:100%;height:100%' viewBox='0 0 70 70'%3E%3Cg class='base'%3E%3Cg fill='none' fill-rule='evenodd' class='main-fill'%3E%3Cpath d='M33.765 17.294C26.725 17.294 21 23.02 21 30.06c0 7.04 5.725 12.765 12.765 12.765 1.876 0 3.657-.416 5.263-1.146l6.266 9.793c.383.663.871 1.235 1.647 1.235 1.202 0 2.059-.818 2.059-2.059.007-.347-.225-.911-.412-1.235l-6.305-9.857a12.726 12.726 0 0 0 4.246-9.496c0-7.04-5.724-12.765-12.764-12.765zm0 1.647c6.15 0 11.117 4.968 11.117 11.118s-4.967 11.117-11.117 11.117A11.105 11.105 0 0 1 22.647 30.06c0-6.15 4.968-11.118 11.118-11.118z' class='main-fill'/%3E%3C/g%3E%3C/g%3E%3Cstyle%3E.main-fill%7Bfill:%23fff%7D%3C/style%3E%3C/svg%3E"); padding: 13px 10%; background-repeat: no-repeat; background-color: #a03f6e; -webkit-background-size: 50px 50px; -moz-background-size: 50px; -o-background-size: 50px; background-size: 50px; background-position: center center; margin: 0px; height: 40px; position: relative; top: 10px; left: 0px; }
div#search { position: absolute; top: 125px; left: 0; right: 0; margin: auto; width: 100%; max-width: 1200px; z-index: 15; background-color: white; height: 40px; }
div#search:focus, div#search:focus-within { outline: 1px solid #dadada; }
div#search input#q { width: 80%; display: inline; border: 0px; height: 40px; padding-left: 6px; float: left; height: 0px; width: 0px; padding: 0px; padding-left: 10px; border-bottom: 1px solid #aaa; font-size: 20px; font-family: 'Montserrat'; text-align: center; -webkit-box-shadow: inset 0 0 20px 20px white; -moz-box-shadow: inset 0 0 20px 20px white; box-shadow: inset 0 0 20px 20px white; -webkit-transition: 0.2s all ease-in; -o-transition: 0.2s all ease-in; -moz-transition: 0.2s all ease-in; transition: 0.2s all ease-in; }
div#search input#q:focus { outline-offset: 1px; }
input#q:focus { font-weight: 600; color: #444; -webkit-transition: 0.2s all ease-in; -o-transition: 0.2s all ease-in; -moz-transition: 0.2s all ease-in; transition: 0.2s all ease-in; }
div#search input#q::-webkit-input-placeholder { font-size: 14px; }
div#search input#q:-moz-placeholder { font-size: 14px; }
div#search input#q::-moz-placeholder { font-size: 14px; }
div#search input#q:-ms-input-placeholder { font-size: 14px; }
div#search input#q::-ms-input-placeholder { font-size: 14px; }
div#search input#q::placeholder { font-size: 14px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="search">
<form action="#" method="get" id="sform" name="sform">
<input id="q" type="text" placeholder="Search...">
<a onclick="if ($('#search input#q').val().length > 3) {document.sform.submit()}else if($('input#q').width() == 0){$('#search input').height('40px').animate({width:'80%'},350);}else{$('#search input').focus();}" rel="nofollow"></a>
</form>
</div>
Tick the border-bottom on/off on the input and watch the padding be applied/unapplied
Am I going crazy or is this what should happen? I mean, personally I'd think it'd be the other way round, padding enables border.
Also if it helps, Chrome 68 Win10.
So I have a tooltip on tumblr and everything about the code is working except the max width, it's stuck at 75px. I've changed it to 250px and 300px and it refuses to stretch with the words in the tooltip.
Code:
a[tooltip]:hover:after {
position: absolute;
z-index: 99999999;
max-width: 300px;
min-width: 60px;
border: 1px solid #bababa;
padding: 6px;
margin: -27px 0px 0px 28px;
background-color: #ffffff;
color: #1a2242;
font-family: arial;
font-size: 7px;
line-height: 12px;
letter-spacing: 1px;
text-transform: uppercase;
font-weight: none;
text-align: center;
box-shadow: rgba(0, 0, 0, 0.04)0 2px 4px;
opacity: 1;
content: attr(tooltip);
transition-duration: 0.6s;
-moz-transition-duration: 0.6s;
-webkit-transition-duration: 0.6s;
-o-transition-duration: 0.6s;
}
#s-m-t-tooltip {
position: absolute;
z-index: 99999999;
max-width: 300px;
min-width: 60px;
border: 1px solid #bababa;
padding: 6px;
margin: -27px 0px 0px 28px;
background-color: #ffffff;
color: #1a2242;
font-family: arial;
font-size: 7px;
line-height: 12px;
letter-spacing: 1px;
text-transform: uppercase;
font-weight: none;
text-align: center;
box-shadow: rgba(0, 0, 0, 0.04)0 2px 4px;
opacity: 1;
outline: 0px solid #ddd;
-moz-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
}
Link
Any help is appreciated and if you need more information, let me know.
add width: 100%; for your pseudo element, also you can use box-sizing so that the width and height properties set the dimensions of the content rather than the content.
`
a[tooltip]:hover:after {
width: 100%;
box-sizing: border-box;
position: absolute;
z-index: 99999999;
max-width: 300px;
min-width: 60px;
border: 1px solid #bababa;
padding: 6px;
margin: -5px 0 0 28px;
background-color: #ffffff;
color: #1a2242;
font-family: arial;
font-size: 7px;
line-height: 12px;
letter-spacing: 1px;
text-transform: uppercase;
font-weight: none;
text-align: center;
box-shadow: rgba(0, 0, 0, 0.04)0 2px 4px;
opacity: 1;
content: attr(tooltip);
transition-duration: 0.6s;
-moz-transition-duration: 0.6s;
-webkit-transition-duration: 0.6s;
-o-transition-duration: 0.6s;
}
#s-m-t-tooltip {
position: absolute;
z-index: 99999999;
width: 300px;
max-width: 200px;
min-width: 60px;
border: 1px solid #bababa;
padding: 6px;
margin: -27 0 0 28px;
background-color: #ffffff;
color: #1a2242;
font-family: arial;
font-size: 7px;
line-height: 12px;
letter-spacing: 1px;
text-transform: uppercase;
font-weight: none;
text-align: center;
box-shadow: rgba(0, 0, 0, 0.04)0 2px 4px;
opacity: 1;
outline: 0px solid #ddd;
-moz-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
}
Link
The reason it's not working is because you have a width:100% set on the a:after pseudo-element. That property will set the width of the element to that of it's parent, in this case your a is a child of your <div class="markericon1">. You can see that if you change just the width of <div class="markericon1"> to something higher you will get the result you want.
.markericon1 {
width:300px;
}
I want to change the image on the button to this white version of it:http://res.cloudinary.com/djxai1v1e/image/upload/v1498062883/HR-Connect-Logowhite_fb7duw.png when hovered on. I thought I would just add a background-image to the :hover but that didn't work. Does anyone know how I can accomplish this? Anything helps, Cheers!
.button_slidehr {
color: #156466;
border: 1px solid rgba(21,100,102,0.35);
border-radius: 0px;
/* extend left padding */
padding: 18px 15px 18px 62px;
position: relative;
display: inline-block;
font-family: Verdana;
font-size: 14px;
margin-bottom: 20px;
letter-spacing: 1px;
background-color: rgba(255,255,255,0.3);
cursor: pointer;
box-shadow: inset 0 0 0 0 #156466;
-webkit-transition: ease-out 0.4s;
-moz-transition: ease-out 0.4s;
transition: ease-out 0.4s;
}
.slide_downhr:hover {
color:white;
border: 1px solid transparent;
box-shadow: inset 0 100px 0 0 #156466;
}
.button_slidehr:after {
content: "";
display: inline-block;
position: absolute;
left: 10px;
top: 0;
width: 100%;
height: 100%;
background-image: url(http://res.cloudinary.com/djxai1v1e/image/upload/v1498058230/HR-Connect-Logo_hjbrmn.png);
background-position: left center;
background-repeat: no-repeat;
background-size: auto 80%;
}
<div class="button_slidehr slide_downhr">Contact HR Now></div>
.button_slidehr {
color: #156466;
border: 1px solid rgba(21,100,102,0.35);
border-radius: 0px;
/* extend left padding */
padding: 18px 15px 18px 62px;
position: relative;
display: inline-block;
font-family: Verdana;
font-size: 14px;
margin-bottom: 20px;
letter-spacing: 1px;
background-color: rgba(255,255,255,0.3);
cursor: pointer;
box-shadow: inset 0 0 0 0 #156466;
-webkit-transition: ease-out 0.4s;
-moz-transition: ease-out 0.4s;
transition: ease-out 0.4s;
}
.slide_downhr:hover {
color:white;
border: 1px solid transparent;
box-shadow: inset 0 100px 0 0 #156466;
}
.button_slidehr:hover:after {
background-image: url(http://res.cloudinary.com/djxai1v1e/image/upload/v1498062883/HR-Connect-Logowhite_fb7duw.png);
}
.button_slidehr:after {
content: "";
display: inline-block;
position: absolute;
left: 10px;
top: 0;
width: 100%;
height: 100%;
background-image: url(http://res.cloudinary.com/djxai1v1e/image/upload/v1498058230/HR-Connect-Logo_hjbrmn.png);
background-position: left center;
background-repeat: no-repeat;
background-size: auto 80%;
}
<div class="button_slidehr slide_downhr">Contact HR Now></div>
.slide_downhr:hover:after {
background-image: url(http://res.cloudinary.com/djxai1v1e/image/upload/v1498062883/HR-Connect-Logowhite_fb7duw.png);
}
Can anyone help me with wrapping of the text around the + box ? I can't seem to get it to work. I have a jfiddle that you can refer to. Hope anyone out there can assist me.
Here's the JSFiddle.
And here is the code:
.video-box {
float: left;
width: 31%;
max-width: 240px;
height: 214px;
background: #232323;
margin: 0 1% 2%;
}
.video-box h3 {
display: table-cell;
vertical-align: middle;
margin: 0;
font-size: 1.0em;
line-height: 1.2;
}
.addtoplaylist-videotext:before {
border: solid;
border-color: #222 transparent;
border-width: 6px 6px 0 6px;
bottom: -8px;
content: "";
left: 80%;
position: absolute;
display: inline-block;
z-index: 99;
border-top: 10px solid rgba(0, 0, 0, 0.6);
}
a {
color: #FFFFFF;
}
.video-txt {
position: absolute;
bottom: 0;
right: 0;
font-size: 1.1em;
line-height: 16px;
background: #000;
padding: 0 3px;
color: #fff;
}
.addtoplaylist-videotext {
background-color: #ffffff;
background-color: rgba(0, 0, 0, 0.6);
border-color: rgba(0, 0, 0, 0.6);
border-right-color: #ffffff;
border-radius: 5px;
top: -50px;
color: #ffffff;
left: -100px;
padding: 5px 5px;
position: relative;
z-index: 99;
width: 120px;
height: 15px;
text-align: center;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#1e78a0', endColorstr='#1e78a0');
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
cursor: pointer;
display: none;
}
.viewplaylist-videotext:before {
border: solid;
border-color: #222 transparent;
border-width: 6px 6px 0 6px;
bottom: -8px;
content: "";
left: 80%;
position: absolute;
display: inline-block;
z-index: 99;
border-top: 10px solid rgba(0, 0, 0, 0.6);
}
.viewplaylist-videotext {
background-color: #ffffff;
background-color: rgba(0, 0, 0, 0.6);
border-color: rgba(0, 0, 0, 0.6);
border-right-color: #ffffff;
border-radius: 5px;
top: -50px;
color: #ffffff;
left: -100px;
padding: 5px 5px;
position: relative;
z-index: 99;
width: 120px;
height: 15px;
text-align: center;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#1e78a0', endColorstr='#1e78a0');
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
cursor: pointer;
display: none;
}
.addtoplaylist-video:hover .addtoplaylist-videotext {
display: block;
}
.viewplaylist-video:hover .viewplaylist-videotext {
display: none;
}
.title {
color: #FFFFFF;
}
.maintainhere-browse {
float: right;
height: 30px;
margin-left: 3px;
margin-top: 20px;
position: relative;
}
.toggle2 {
position: relative;
float: right;
margin-right: 10px;
margin-top: -15px;
background-color: #f36666;
width: 20px;
height: 18px;
color: #FFFFFF;
font-size: 12px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
cursor: pointer;
font-weight: bold;
}
.addtoplaylist-video {
position: relative;
bottom: 0px;
right: 0px;
width: auto;
height: auto;
image-rendering: -moz-crisp-edges;
display: inline-block;
cursor: pointer;
}
.viewplaylist-video {
display: none;
}
}
.addtoplaylist-video a {
color: #FFFFFF !important;
}
.viewplaylist-video a {
color: #FFFFFF !important;
}
.play-ico {
background-position: -2px -1351px;
background: url(/blob/1086/1386905708000/a-ico-sprite-png-data.png) no-repeat -2px -1316px;
text-indent: -9999px;
position: absolute;
top: 0;
left: 0;
width: 33px;
height: 33px;
overflow: hidden;
text-align: left;
}
<div class="video-box">
<div class="video-box-content-holder" data-createtime="1385208101000" data-viewcounts="559">
<div class="img" style="max-height:135px">
<a href="/news/video/typhoon-haiyan-politics/897416.html">
<img src="http://i58.tinypic.com/2uj2o3t.jpg" alt="" width="240" height="135" />
<span class="play-ico">play</span>
<span class="video-txt">01:54</span>
</a>
<span class="add-txt">Asia Pacific</span>
</a>
</div>
<div class="txt-box">
<!-- the class toggle 2 is for 2nd component, diff css-->
<div class="maintainhere-browse">
<div id="browsevideos_1" class="toggle2">
<div class="addtoplaylist-video">
<img src="http://i61.tinypic.com/rtdv2b.png" width="12" height="11" alt="add" class="addplaylisticonimg-browse">
<span class="addtoplaylist-videotext"> Add To Playlist!</span>
</div>
<div class="viewplaylist-video">
<img src="http://i59.tinypic.com/2n98as.png" width="17" height="9" alt="viewicon" class="viewplaylisticonimg-browse">
<span class="viewplaylist-videotext"> View Playlist!</span>
</div>
</div>
</div>
<!--endofmaintainhere-->
<div class="title">
<h3 style="color:white;">Typhoon Haiyan: Politics gets in the way of saving lives i want the text to wrap around </h3>
<span class="date" style="color:white;">23 Nov 2013</span>
</div>
<!-- title -->
</div>
</div>
</div>
So the basic problem is assigning display: table to .video-box h3.
Once that is removed, it actually does wrap. The problem is now that you won't see it with that text, because it so happens that those words would move to the next line anyway. I've added more words and removed the height of the container and you can see this working:
DEMO showing text is wrapping without table-cell property.
In your case, I'd consider rewriting some of the code around positioning the .maintainhere-browse button:
.maintainhere-browse{
...
/*margin-top:20px; Remove this line */
...
}
.toggle2 {
...
margin-top: 10px; /* Changed this value */
...
}
Demo