different styles for labels inside CSS tab setup - html

Hopefully tis is a reallllly easy fix that I'm just not seeing, but I've been trying every solution I could find that arched even close to this in previously submitted questions and I'm just getting nowhere.
The short of it: I've got a CSS tab setup working that's great, EXCEPT for when it comes to styling the actual labels on the tabs. It works great with a single style, but as soon as I try to introduce a secondary font style (bringing the font size down to 11px), the right hand side of the tab disappears.
And unfortunately I NEED to be able to have those two different font sizes/styles displayed in the tab label. I've tried using span, div, etc. treatments but everything makes the right border of the tab go away. Any help is HUGELY appreciated!
Here's a fiddle: http://jsfiddle.net/wKtPL/
Here's my sample HTML:
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Library <div class='tab-count'> 123</div></label>
<div class="content">
content goes here
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Institution’s Subscriptions</label>
<div class="content">
content goes here
</div>
</div>
<div class="tab">
<input type="radio" id="tab-3" name="tab-group-1">
<label for="tab-3">Copyright Agent</label>
<div class="content">
content goes here
</div>
</div>
<div class="tab">
<input type="radio" id="tab-4" name="tab-group-1">
<label for="tab-4">Internet Archive</label>
<div class="content">
content goes here
</div>
</div>
<div class="tab">
<input type="radio" id="tab-5" name="tab-group-1">
<label for="tab-5">HathiTrust</label>
<div class="content">
content goes here
</div>
</div>
And the CSS behind it:
.tabs {
position: relative;
min-height: 550px;
clear: both;
margin: 25px 0;
}
.tab {
float: left;
}
.tab label {
background: #dadcde;
color: #3f4b54;
padding: 10px;
border: 1px solid #ccc;
margin-left: -1px;
position: relative;
left: 1px;
-moz-border-radius-topright:3px;
-webkit-border-top-right-radius:3px;
border-top-right-radius:3px;
-moz-border-radius-topleft:3px;
-webkit-border-top-left-radius:3px;
border-top-left-radius:3px;
font-size: 14px;
font-weight:bold;
margin-right:5px;
}
.tab-count {
font-size: 11px;
}
.tab [type=radio] {
display: none;
}
.content {
position: absolute;
top: 28px;
left: 0;
background: white;
right: 0;
bottom: 0;
padding: 20px;
border: 1px solid #ccc;
overflow: hidden;
}
.content > * {
opacity: 0;
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
-ms-transform: translateX(-100%);
-o-transform: translateX(-100%);
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-ms-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
[type=radio]:checked ~ label {
background: white;
border-bottom: 3px solid white;
z-index: 2;
}
[type=radio]:checked ~ label ~ .content {
z-index: 1;
}
[type=radio]:checked ~ label ~ .content > * {
opacity: 1;
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
}

By secondary font style do you mean the div nested in the label? If that's the one with class .tab-count you could set float:right. That will keep it in the same line.
.tab-count {
font-size: 11px;
float:right;
}

A couple of things, firstly the 123 is being hidden under the .content so you need a taller top value.
Secondly, your labels, while being position: relative; are still only being implicitly rendered as display: inline;, so it's hiding the 123 div underneath the label itself.
http://jsfiddle.net/wKtPL/1/
.tab label {
[ ... ]
display: inline-block;
min-height: 2.5em;
}
.content {
[ ... ]
top: 60px;
}
... and muck with styling as you need.

This is caused by the usage of a block element inside your label element, which is an inline element. To fix this, change your <div class='tab-count'> 123</div> to <span class='tab-count'> 123</span>. Here is a demo of it.
If you want to allow block-level elements to be placed within inline elements, you could like #setek said, use the alternative inline-block which is a kind of hybrid of block elements and inline elements.
You should never use block elements inside inline elements, since that will cause problems like this one. What was happening was that the styles for the inline <label> tag were being dragged across 2 lines, since the <div> was taking up an extra line. That dragged the left border down a line too, which is why you didn't see it anymore (it was below the other tabs).

Related

How to rotate an input toggle image properly?

I've got a simple input toggle that reveals text when 'toggled'.
Codepen
HTML
<div class="window">
<input type="checkbox" id="punch" class="toggle">
<label for="punch">
<img class="arrow" src="http://45.79.67.59/moreinfo_arrow.png">
</label>
<div>
<h3>codepen.io</h3>
</div>
</div>
CSS
div.window {
color: #000;
width: 100%;
background: #fff;
margin: 0px;
font-family: Arial Black, sans-serif;
font-size: 20px;
}
div.window label{
display: block;
width: 1%;
transition: all 0.75s 0.25s;
transform: rotate(0);
}
input.toggle ~ div {
height: 0px; margin: .1rem;
overflow: hidden;
transition: .6s all cubic-bezier(0.730, -0.485, 0.145, 1.620)
}
input.toggle:checked ~ div { height: 60px; }
input.toggle:checked + label { transform: rotate(180deg); }
input.toggle { display: none; }
When the toggle <img> is 'checked', I'd like it to rotate 180˚, however, I've had trouble making the image rotate on it's center axis. It currently rotates on it's edge: good for eliciting a chuckle... not so good for potential users.
Any help is very much appreciated!
Problem
The origin of your transformation is not the center of the image. So it rotates about the wrong reference point. See the following picture:
This picture is showing the result of rotating a square using transform: rotate(45deg) with different transform-origin values.
Solution
Normally just add transform-origin: center center; to the transform property (but to be honest, that's also the default value).
So your actual problem is that you specified the transition on the parent (of the image) what means it will take the center of the parent. Since you specified the width as 1% the center isn't the same as the center of the image. So to solve this I've felt free to change this to the width of the image (what is in this case width:200px;).
Alternatively you could specify the origin manually with absolute values (in your case transform-origin:100px 100px;).
See JSFiddle.

parent content height not expanding with tabs content height

I am trying to display tabs content in pure css, but i am unable to fix this height for parent. if content is more in tabs content parent content(red area) not expanding. please help to to expanding the parent (red area) when content is more and after clicking on other tab, previous tab content not hidden. please need help in two cases.
.tabs-container {
background: red;
padding: 30px;
height: 100%;
}
.tabs {
position: relative;
clear: both;
margin: 25px 0;
}
.tab {
display: block;
width: 220px;
}
.tab label {
background: #eee;
padding: 10px;
border: 1px solid #ccc;
border-right: none;
margin-left: -1px;
position: relative;
left: 1px;
width: 200px;
display: inline-block
}
.tab [type=radio] {
display: none;
}
.content {
position: absolute;
top: 0px;
left: 220px;
background: white;
right: 0;
padding: 20px;
border: 1px solid #ccc;
overflow: hidden;
}
.content > * {
opacity: 0;
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
-ms-transform: translateX(-100%);
-o-transform: translateX(-100%);
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-ms-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
[type=radio]:checked ~ label {
background: white;
border-bottom: 1px solid #ccc;
z-index: 2;
}
[type=radio]:checked ~ label ~ .content {
z-index: 1;
}
[type=radio]:checked ~ label ~ .content > * {
opacity: 1;
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
}
<div class="tabs-container">
<div class="tabs">
<!--tabs-->
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked="">
<label for="tab-1">Tab One</label>
<!--tabs-content-->
<div class="content">
<p>Our expert team allows us to offer Protective Coating services, which is famous for its variety of benefits such as offering universal strainers for light shades, offers breath ability for preventing moisture, curing a tough flexible & abrasion
resistant coating, resistant to chalking and flaking and offering strong bonding on cement concrete, asbestos & mild steel. Our range of services finds its application in various areas like chajjas, external vertical walls, china mosaic tiles,
water tanks (externally), sloppy roofs, asbestos roof, roof terraces and stone walls. These services consist of acrylic elastomeric dust proof coating and polyurethane waterproof coatings. Protective Coating Our expert team allows us to offer
Protective Coating services, which is famous for its variety of benefits such as offering universal strainers for light shades, offers breath ability for preventing moisture, curing a tough flexible & abrasion resistant coating, resistant to
chalking and flaking and offering strong bonding on cement concrete, asbestos & mild steel. Our range of services finds its application in various areas like chajjas, external vertical walls, china mosaic tiles, water tanks (externally), sloppy
roofs, asbestos roof, roof terraces and stone walls. These services consist of acrylic elastomeric dust proof coating and polyurethane waterproof coatings.</p>
</div>
<!--tabs-content end-->
</div>
<!--tabs-->
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1" checked="">
<label for="tab-2">Tab One</label>
<!--tabs-content-->
<div class="content">
<p>Stuff for Tab One</p>
</div>
<!--tabs-content end-->
</div>
<!--tabs-->
<div class="tab">
<input type="radio" id="tab-3" name="tab-group-1" checked="">
<label for="tab-3">Tab One</label>
<!--tabs-content-->
<div class="content">
<p>Protective Coating
</p>
</div>
<!--tabs-content end-->
</div>
</div>
</div>
working codepen link
for your issue (hope it is inside html and body) then
.tabs-container {background: red;padding: 30px;height: 100%;overflow:auto;}
will work for you.
jsbin link
If i understood maybe it
html,
body {
height: 100%;
}

HTML circle div with image trying to get hovering text

I'm trying to get a square div that says "read more" when hovering over a circle div with a picture inside it. Been trying different things and haven't found a working solution on google.
HTML
<div class = "portfolio" id = "first"> <!-- makes the circle -->
<a href = "cake-page.html">
<div class = "readm"> Read more </a> </div>
<img src = "cake.jpg" />
<p> The cake </p> </div>
CSS
.portfolio {
/* the circles on the portfolio-page */
position: relative;
border-radius: 100%;
display: inline-block;
height: 150px;
width: 150px;
border: 2px solid purple;
}
.portfolio.img {
opacity: 1;
transition: 1s ease;
background-size: 90px 0px;
overflow: hidden;
border-radius: 100px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
width: 150px;
height: 150px;
}
.portfolio:hover {
/* hover effect on portfolio circles */
opacity: 0.6;
-webkit-transform: scale(1.2);
-ms-transform: scale(1.2);
transform: scale(1.2);
transition: 1 ease;
visibility: visible;
}
So either the text pushed the image down or it stays in the top of the circle and I can't get it to hover together with the other hover effect. I want the "read more" to pop-up in a rectangular div when hovering over together with the other hover effect.
I did not include the div class "readm" since I can't get it to work. FYI I'm pretty new to this. Thanks.
A little tough without a working example and it'd be good to see the readm css since we need to see what isn't working. That said, have you tried something like this:
.readm {
opacity:0;
position:absolute;
top:50%;
left:50%;
transform:translate(-50%, -50%);
}
.portfolio:hover .readm {
opacity:1;
}
Also I would place the start of that a tag inside the readm div.
First, you need to fix your markup.
You are closing the anchor ("a") tag before closing a DIV. That alone will make your CSS fail.
I presume you want to close the DIV like so:
<div class="readm">Read more</div>

How can I make css transition last after unhovering?

I created a div that when hovering, reveals a form. the problem is each time im moving the cursor the transition takes place and filling the form become impossible. how can i make the transition work once and than stay/ last for long time?
*i found some information about the delay option but i didn't find a way to modify the delay time separately for the first hovering and then for when the cursor moves out of the div (when "unhovering"). im looking for a pure css sulotion
HTML:
<form id="women">
<label >
<input type="text" name="fullName" >
</label>
</form>
<div id="wcover"></div>
css:
#wcover{
right: 177px;
z-index: 1;
top: 291px;
position: absolute;
width: 337px;
height: 402px;
background: yellow;
-webkit-transition: height 2s; /* For Safari 3.1 to 6.0 */
transition: height 2s;
}
#wcover: hover{
height: 0px;
background:black;
}
Assuming your div is before the form, you may use a transition (e.g. of the opacity property) with a long delay on "unhover"
e.g.
Markup(*)
<div id="wcover">hover me</div>
<form id="women">
<label >whats your name</label>
<input type="text" name="fullName">
</form>
Css
form {
opacity: 0;
transition: opacity 1s 999999s;
}
div:hover + form {
opacity: 1;
transition: opacity 0s;
}
After the hover event, thanks to the delay inserted, the user may takes up to 999.999 seconds (approx.ly 277.7 hours) to fill the form.
Live Example: http://codepen.io/anon/pen/dPYOLB
(*)As a side note, for a matter of markup validation, you can't insert an heading into a label.
You properly need some jQuery here....
$("#wcover").hover(function() {
$("#wcover").addClass("hovered");
});
And some CSS:
.hovered { //Properties here }
Alternatively, you could make use of a checkbox to show/hide your div on click. It is not very clear from your question as to whether you are showing the form which is shown in your code, or the div itself which contains another form.
Am assuming, that you have a form inside the div.
#wcover {
opacity: 0;
transition: all 1s;
}
label[for=chk] { cursor: pointer; }
#chk { display: none; }
#chk:checked + #wcover { opacity: 1; }
<label>
What's your name?
<input type="text" id="fullName" />
</label>
<br /><br />
<label for="chk">Click to Show/Hide Complete Form</label>
<input id="chk" type="checkbox" />
<div id="wcover">
<form id="women">
<h2>Complete Form</h2>
<input type="text" /><br/>
<input type="text" /><br/>
</form>
</div>
Could you not wrap it all in a containing div and apply the hover to that?
<div id="form-container">
<form id="women">
<label >
<input type="text" name="fullName" >
</label>
</form>
<div id="wcover"></div>
</div>
Hi Use CSS transitionn delay property
#wcover{
right: 177px;
z-index: 1;
top: 291px;
position: absolute;
width: 337px;
height: 402px;
background: yellow;
-webkit-transition: height 2s; /* For Safari 3.1 to 6.0 */
transition: height 2s;
transition-delay: 1s;
}
#wcover: hover{
height: 0px;
background:black;
transition-delay: 0s;
}
The above css will give delay after the mouse out. just reverce it to do it other way

Applying a certain effect to input[type=submit]

I'm using a CSS hover effect on buttons and menu-links. The links work fine because they are anchor tags, while the buttons do not work since they are used in forms as input[type=submit].
The HTML:
<div class="submit">
<span data-hover="Send">
<input type="submit" value="Send">
</span>
</div>
The .submit-wrapper class is used for decoration (as seen in the CSS below), while the span applies the actual hover effect.
The CSS:
.submit /* Need this to hide the second text -- otherwise it will show beneath */ {
overflow: hidden;
}
.submit > span {
position: relative;
display: block;
-webkit-transition: -webkit-transform 0.3s;
-moz-transition: -moz-transform 0.3s;
transition: transform 0.3s;
}
.submit > span::before /* The effect in place */ {
padding-top: 49px;
content: attr(data-hover);
position: absolute;
-webkit-transform: translate3d(0,0,0);
-moz-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
left: 28px;
top: 0;
letter-spacing: normal;
}
.submit:hover > span, .submit:focus > span /* The actual effect on hover */ {
-webkit-transform: translateY(-100%);
-moz-transform: translateY(-100%);
transform: translateY(-100%);
}
Here's the problem: I cannot click on the button. It shows the default cursor and completely ignores the fact that it's a button (an input submit type). So I have two questions:
1. Is it possible to use an anchor tag instead of an input type="submit"?
2. If not, how do I make the input type="submit" clickable?
For me, when I put that into jsfiddle, I can't click the button because your translate is moving it offscreen. When I remove that I can click the button just fine.
Otherwise, you can use a link that has jQuery attached to it so when it's clicked, submit the form. see http://api.jquery.com/submit/