div not expanding with text - css

HTML Code
<div class="container">
<div class="tip_text">D</div>
<div class="tip_content">test</div>
</div>
<br /><br /><br />
<div class="container">
<div class="tip_text">D2</div>
<div class="tip_content">test test test test test test test</div>
</div>
CSS Code
.container{
position: relative;
float: left;
}
.tip_text{
position: relative;
float:left;
width: 130px;
height: 30px;
margin: 0px;
padding: 2px;
text-align: left;
line-height: 28px;
font-size: 16px;
font-weight: bold;
border: 1px solid #acacac;
cursor:help;
}
.tip_content{
background: #333;
color: #fff;
padding: 10px 15px;
z-index: 98;
min-height: 15px;
position:absolute;
left: 100%;
font-size: 12px;
}
The above code has the following issue which I am trying to solve. The "tip_content" divs do not expand when a lot of text is placed into them. I cannot figure out why. I do not want to have a set width, I would prefer that they grow based on the amount of text put within. This should be happening by default as is the behavior of divs, but in this case it is not. If anyone has insight into this issue it would be greatly appreciated.
http://jsfiddle.net/Qyrjf/

white-space: nowrap;
This seems to fix the problem. Here is the full code in case people are interested in the application of the solution. It is using CSS and CSS3 to create tooltips.
HTML
<div class="container">
<div class="tip_text">D</div>
<div class="tip_content">test</div>
</div>
<br /><br /><br />
<div class="container">
<div class="tip_text">D2</div>
<div class="tip_content">test test test test test test test</div>
</div>
CSS (full)
.container{
position: relative;
float: left;
}
.tip_text{
position: relative;
float:left;
width: 130px;
height: 30px;
margin: 0px;
padding: 2px;
text-align: left;
line-height: 28px;
font-size: 16px;
font-weight: bold;
border: 1px solid #acacac;
cursor:help;
}
.tip_text:hover + .tip_content{
opacity: .9;
visibility: visible;
margin-left: 10px;
}
.tip_content:before{
border: solid;
border-color: transparent #333;
border-width: 6px 6px 6px 0;
content: "";
z-index: 99;
position:absolute;
left:-6px;
top:12px;
}
.tip_content{
background: #333;
color: #fff;
padding: 10px 15px;
z-index: 98;
min-height: 15px;
float: left;
left: 100%;
font-size: 12px;
position: absolute;
white-space: nowrap;
-moz-box-shadow: 2px 2px 2px #666;
-webkit-box-shadow: 2px 2px 2px #666;
box-shadow: 2px 2px 2px #666;
opacity: 0;
margin-left: 20px;
visibility: hidden;
-webkit-transition-property:opacity, visibility, margin-left;
-webkit-transition-duration:0.2s, 0.2s, 0.1s;
-webkit-transition-timing-function: ease-in-out, ease-in-out, ease-in-out;
-moz-transition-property:opacity, visibility, margin-left;
-moz-transition-duration:0.2s, 0.2s, 0.1s;
-moz-transition-timing-function: ease-in-out, ease-in-out, ease-in-out;
-o-transition-property:opacity, visibility, margin-left;
-o-transition-duration:0.2s, 0.2s, 0.1s;
-o-transition-timing-function: ease-in-out, ease-in-out, ease-in-out;
transition-property:opacity, visibility, margin-left;
transition-duration:0.2s, 0.2s, 0.1s;
transition-timing-function: ease-in-out, ease-in-out, ease-in-out;
}

Related

CSS Border Transition - Weird effect

When I hover over the corner of the element I am getting a weird constant hover and hover out effect, how can I fix this?
HTML
<h2>
HELLO
</h2>
CSS
h2 {
position: absolute;
background: rgba(2,35,64,0.58);
width: calc(100% - 97px);
height: calc(100% - 88px);
line-height: calc(100% + 70px);
top: 0;
left: 0;
display: block;
font-size: 18px;
text-transform: uppercase;
text-align: center;
color: #FFF;
border: solid 20px rgba(2,35,64,0);
padding: 20px;
margin: 0px;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s linear;
-o-transition: all 0.3s linear;
transition: all 0.3s linear;
cursor: pointer;
}
h2:hover {
border: solid 5px #FFF;
padding: 10px;
margin: 25px;
background: transparent;
}
h2.woocommerce-loop-category__title:hover {
border: solid 5px #FFF;
padding: 10px;
margin: 25px;
background: transparent;
}
http://jsfiddle.net/xc7vjstn/1/
change the background from transparent to what ever color you want and you will see the content plus if you want to keep it online like small box then margin and padding is what you need to play with.
h2:hover {
border: solid 5px #FFF;
padding: 10px;
margin: 25px;
background: blue;
}
The margin in h2:hover is causing the behavior removing the margin fixed the problem
h2:hover {
border: solid 5px #FFF;
padding: 10px;
/*margin: 25px; */
background: transparent;
}
Here is my solution, please check the live example below:
h2 {
position: absolute;
background: rgba(2, 35, 64, 0.58);
width: calc(100% - 97px);
height: calc(100% - 88px);
line-height: calc(100% + 70px);
top: 0;
left: 0;
font-size: 18px;
text-transform: uppercase;
text-align: center;
color: #FFF;
border: solid 20px rgba(2, 35, 64, 0);
padding: 20px;
margin: 0 auto;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s linear;
-o-transition: all 0.3s linear;
transition: all 0.3s linear;
cursor: pointer;
}
h2:hover {
background: transparent;
-ms-transform: scale(0.9);
-webkit-transform: scale(0.9);
transform: scale(0.9);
}
<h2>
HELLO
</h2>

The length of first tab persists to be active

My first tab longer than second one. In first tab there are links and images with anchor link.The problem is first tab's links are still active although I click on second tab and lays down on my tag cloud, so prevent them to be clickable. I would like to know why links of first tab are still clickable althoug they are not appearing?
fiddle
HTML
<section class="tabs">
<input id="tab-1" type="radio" name="radio-set" class="tab-selector-1" checked="checked" />
<label for="tab-1" class="tab-label-1">About</label>
<input id="tab-2" type="radio" name="radio-set" class="tab-selector-2" />
<label for="tab-2" class="tab-label-2">Services</label>
<input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" />
<label for="tab-3" class="tab-label-3">Work</label>
<div class="clear-shadow"></div>
<div class="tab-content">
<div class="content-1">
Link
<a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
<img src="#" width="250" height="250"/></a>
Link
<a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
<img src="#" width="250" height="250"/></a>
Link
<a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
<img src="#" width="250" height="250"/></a>
Link
<a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
<img src="#" width="250" height="250"/></a>
</div>
<div class="content-2">
<h2>Most Commented</h2>
</div>
</div>
</section>
Link
CSS
.tabs {
position: relative;
margin: 40px auto;
width: 100%;
height: auto;
}
.tabs input {
position: absolute;
z-index: 1000;
width: 100px;
height: 40px;
left: 0px;
top: 0px;
opacity: 0;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
cursor: pointer;
}
.tabs input#tab-2{
left: 100px;
}
.tabs input#tab-3{
left: 220px;
}
.tabs input#tab-4{
left: 340px;
}
.tabs label {
background: #5ba4a4;
background: -moz-linear-gradient(top, #5ba4a4 0%, #4e8c8a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#5ba4a4), color-stop(100%,#4e8c8a));
background: -webkit-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
background: -o-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
background: -ms-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
background: linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
font-size: 15px;
line-height: 40px;
height: 40px;
position: relative;
padding: 0 12px;
float: left;
display: block;
width: 80px;
color: #385c5b;
letter-spacing: 1px;
text-transform: uppercase;
font-weight: bold;
text-align: center;
text-shadow: 1px 1px 1px rgba(255,255,255,0.3);
border-radius: 3px 3px 0 0;
box-shadow: 2px 0 2px rgba(0,0,0,0.1), -2px 0 2px rgba(0,0,0,0.1);
}
.tabs label:after {
content: '';
background: #fff;
position: absolute;
bottom: -2px;
left: 0;
width: 100%;
height: 2px;
display: block;
}
.tabs input:hover + label {
background: #5ba4a4;
}
.tabs label:first-of-type {
z-index: 4;
box-shadow: 2px 0 2px rgba(0,0,0,0.1);
}
.tab-label-2 {
z-index: 3;
}
.tab-label-3 {
z-index: 2;
}
.tabs input:checked + label {
background: #fff;
z-index: 6;
}
.clear-shadow {
clear: both;
}
.tab-content {
background: #fff;
position: relative;
width: 100%;
height: auto;
z-index: 5;
box-shadow: 0 -2px 3px -2px rgba(0,0,0,0.2), 0 2px 2px rgba(0,0,0,0.1);
border-radius: 0 3px 3px 3px;
}
.tab-content div {
position: absolute;
top: 0;
left: 0;
padding: 10px 40px;
z-index: 1;
opacity: 0;
-webkit-display: flex;
display: flex;
-webkit-flex-flow: column;
flex-flow: column;
-webkit-transition: opacity linear 0.1s;
-moz-transition: opacity linear 0.1s;
-o-transition: opacity linear 0.1s;
-ms-transition: opacity linear 0.1s;
transition: opacity linear 0.1s;
}
.tab-content div img { border: 1px solid #903; position: relative;
}
.tabs input.tab-selector-1:checked ~ .tab-content .content-1,
.tabs input.tab-selector-2:checked ~ .tab-content .content-2,
.tabs input.tab-selector-3:checked ~ .tab-content .content-3 {
z-index: 100;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: opacity ease-out 0.2s 0.1s;
-moz-transition: opacity ease-out 0.2s 0.1s;
-o-transition: opacity ease-out 0.2s 0.1s;
-ms-transition: opacity ease-out 0.2s 0.1s;
transition: opacity ease-out 0.2s 0.1s;
position:relative;
}
.tab-content div h2,
.tab-content div h3{
color: #398080;
}
.tab-content div p {
font-size: 14px;
line-height: 22px;
font-style: italic;
text-align: left;
margin: 0;
color: #777;
padding-left: 15px;
font-family: Cambria, Georgia, serif;
border-left: 8px solid rgba(63,148,148, 0.1);
}
.tab-content li {
overflow: hidden;
list-style: none;
border-bottom: 1px solid #f0f0f0;
margin: 0 0 8px;
padding: 0 0 6px;
}
Because opacity:0 does make your div transparent but it is still there. Change opacity:0 to display:none insteed
fiddle

CSS: round buttons with shadow effect

I'm trying to replicate the navigation buttons here, that's a wix website so it's so hard to inspect elements.
What I have tried is here
https://jsfiddle.net/1vngy4uo/1/
I'm trying many variations, never getting the css 100% correct.
.navButton {
width:15%;
display:inline-block;
position:relative;
background-color:#03314b;
border-radius: 30%;
box-shadow: 2px 2px 2px #888888;
}
.navButton:hover {
background-color:#98b7c8;
}
.navButton span {
width:100%;
display:inline-block;
position:absolute;
border-radius: 30%;
box-shadow: 2px 2px 2px #888888;
}
.navButton .bg {
height:50%;
top:0;
background-color:#3a6076 ;
border-radius: 30%;
box-shadow: 2px 2px 2px #888888;
}
.navButton:hover .bg{
background-color:#afcad9;
}
.navButton .text {
position:relative;
text-align:center;
color:#fff;
vertical-align: middle;
align-items: center;
}
.navButton .text:hover {
color:#000000;
}
and html
<a href="contact.html" class="navButton">
<span class="bg"></span>
<span class="text">Contact</span>
A very similar one, using linear-gradient and less HTML markup
jsFiddle
.navButton {
color: white;
text-decoration: none;
font-family: Helvetica, Arial, sans-serif;
font-size: 14px;
text-align: center;
padding: 0 30px;
line-height: 30px;
display: inline-block;
position: relative;
border-radius: 20px;
background-image: linear-gradient(#335b71 45%, #03324c 55%);
box-shadow: 0 2px 2px #888888;
transition: color 0.3s, background-image 0.5s, ease-in-out;
}
.navButton:hover {
background-image: linear-gradient(#b1ccda 49%, #96b4c5 51%);
color: #03324c;
}
Contact
I just used a div element to implement the same button that you referred. Is this what you want?
https://jsfiddle.net/9L60y8c6/
<div class="test">
</div>
.test {
cursor: pointer;
background: rgba(4, 53, 81, 1) url(//static.parastorage.com/services/skins/2.1212.0/images/wysiwyg/core/themes/base/shiny1button_bg.png) center center repeat-x;
border-radius: 10px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
transition: background-color 0.4s ease 0s;
position: absolute;
top: 0;
bottom: 0;
left: 5px;
right: 5px;
height: 30px;
width: 115px;
}
Would this be a start? You might want to adjust the colors a little.
Note: One can use linear-gradient, though it won't work on IE9, so I use a pseudo instead
.navButton {
width: 15%;
display: inline-block;
position: relative;
background-color: #03314b;
border-radius: 8px;
box-shadow: 2px 2px 2px #888888;
text-align: center;
text-decoration: none;
color: #fff;
padding: 5px;
transition: all 0.3s;
overflow: hidden;
}
.navButton:before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 50%;
width: 100%;
background-color: #335b71;
transition: all 0.3s;
}
.navButton span {
position: relative;
}
.navButton:hover {
transition: all 0.3s;
background-color: #96b4c5;
color: black;
}
.navButton:hover:before {
transition: all 0.3s;
background-color: #b1ccda;
}
<a href="contact.html" class="navButton">
<span>Contact</span>
</a>

Removing top and bottom space on a tag

is there a way to remove invisible space on top/bottom of a <a> tag.
I have tryed removing paddings, margins and other positions.
HTML:
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn"><div class="cog"></div></button>
<div id="myDropdown" class="dropdown-content">
<div class="dop"></div>
Text
</div>
</div>
CSS:
.dropbtn {
height: 34px;
width: 34px;
background: #f0f0f0;
border-radius: 3px;
border: none;
cursor: pointer;
transition: 0.3s ease;
-webkit-transition: 0.3s ease;
-moz-transition: 0.3s ease;
-o-transition: 0.3s ease;
vertical-align: none;
}
.dropbtn:hover, .dropbtn:focus {
background: #ebebeb;
}
.dropdown {
position: relative;
display: inline-block;
margin-top: 100px;
margin-left: 100px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #ffffff;
width: 140px;
border-radius: 3px;
left: -53px;
top: 48px;
}
.dropdown-content a {
color: #b7b7b7;
text-decoration: none;
font-family: OpenSans-Regular;
font-size: 12px;
text-align: center;
display: block;
outline-width: 0px;
}
.show {display:block;}
This is how it looks right now -
This is how it should look like -
Kinds regards, Ričards.
I think you are talking about the line-height property. Try using a low value :
line-height: .8em;
There is no extra padding or margin at the top and bottom of text.
This is normal behaviour of font specification:
Font-size is defined by 13, the white spaces are defined by 14 and probably 15 (since you don't have letters with parts below baseline).
You can override this by force line-height lower than font-size. But you must remember that every font has got different 14 in specification and you must choose ratio line-height/font-size (for example 0.8em) by experiment.
Change line-height to 10px or 12px as you find according to your needs
body {
background: #e0e0e0;
}
.dropbtn {
height: 34px;
width: 34px;
background: #f0f0f0;
border-radius: 3px;
border: none;
cursor: pointer;
transition: 0.3s ease;
-webkit-transition: 0.3s ease;
-moz-transition: 0.3s ease;
-o-transition: 0.3s ease;
vertical-align: none;
}
.dropbtn:hover, .dropbtn:focus {
background: #ebebeb;
}
.dropdown {
position: relative;
display: inline-block;
margin-top: 100px;
margin-left: 100px;
}
.dropdown-content {
position: absolute;
background-color: #ffffff;
width: 140px;
border-radius: 3px;
left: -53px;
top: 48px;
}
.dropdown-content a {
color: #b7b7b7;
text-decoration: none;
font-family: OpenSans-Regular;
font-size: 12px;
text-align: center;
display: block;
outline-width: 0px;
line-height: 12px;
}
.show {display:block;}
<div class="dropdown">
<button class="dropbtn"><div class="cog"></div></button>
<div id="myDropdown" class="dropdown-content">
<div class="dop"></div>
Text
</div>
</div>

Text is not getting wrapped inside a box

I am trying to do a image caption with slide. I have done everything, but the text inside the slide does not wrapped within the slide box. Someone please help in this.
use the JSfiddle link to view the code:
http://jsfiddle.net/anba/t31a4xq0/
HTML
</head>
<body>
<div id="mainwrapper">
<!-- Image Caption 1 -->
<div id="box-1" class="box">
<img id="image-1" src="https://pbs.twimg.com/profile_images/378800000247666963/9b177e5de625a8420dd839bb1561280d.jpeg" width="300" height="200"/>
<span class="caption simple-caption">
<div class="blogp">
Simple Caption
<p >1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950</p>
</div>
</span>
</div>
</body>
</html>
CSS
#mainwrapper {
/*font: 18pt normal Arial, sans-serif;*/
height: auto;
/*margin: 5px 10px ;*/
/*text-align: center;*/
width: 300px;
overflow: visible;
}
/* Image Box Style */
#mainwrapper .box {
border: 5px solid #fff;
cursor: pointer;
height: 182px;
float: left;
margin: 5px;
position: relative;
overflow: hidden;
width: 300px;
-webkit-box-shadow: 1px 1px 1px 1px #ccc;
-moz-box-shadow: 1px 1px 1px 1px #ccc;
box-shadow: 1px 1px 1px 1px #ccc;
}
#mainwrapper .box img {
position: absolute;
left: 0;
-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;
cursor: text;
}
/* Caption Common Style */
#mainwrapper .box .caption {
background-color: rgba(0,0,0,0.7);
position: absolute;
color: #fff;
z-index: 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;
left: 0;
}
/** Caption 1: Simple **/
#mainwrapper .box .simple-caption {
height: 150px;
width: 300px;
display: block;
bottom: -70px;
cursor: text; /*line-height: 100pt;*/
text-align: left;
}
/** Simple Caption :hover Behaviour **/
#mainwrapper .box:hover .simple-caption {
-moz-transform: translateY(-100%);
-o-transform: translateY(-100%);
-webkit-transform: translateY(-40%);
opacity: 1;
transform: translateY(-40%);
}
.blogp{
font-family: Verdana, Geneva, sans-serif;
font-size: 10pt;
color: #FF8000;
padding: 3px 5px 3px 5px;
text-decoration: none;
width:100%;
}
.blogp a{
font-family: "Arial Black", Gadget, sans-serif;
font-size: 14pt;
color: #0080C0;
padding: 3px 5px 3px 5px;
text-decoration: none;
width:400px;
}
Look at the numbers i had used in the html. I have enter 1-50 but it displays only to 23 and the text is not getting wrapped to the next line.
Simply add to your css:
.blogp p{
word-wrap: break-word;
}
UPDATE of your : JSFiddle

Resources