Bootstrap has the following defined in their bootstrap.css file:
.form-control {
display: block;
width: 100%;
height: 38px;
padding: 8px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
I want to create a style exactly like this, but without the width of 100%. And, if anything in .form-control changes, I want to make sure it's reflected in my new style. It's very much like I want a new style that is derived from .form-control but with changes I specify in my new style. Does CSS have syntax that supports this?
You can give your element two classes, then set the second class to overwrite the first. Something like this should work:
<div class="form-control other-class"></div>
Then create a new CSS rule like so:
.form-control.other-class{
width: auto;
}
Here is a fiddle of it in action: http://jsfiddle.net/xu46ed26/
.form-control, .my-other-class {
display: block;
width: 100%;
height: 38px;
padding: 8px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
.my-other-class {
other : rule;
}
Related
I'm using this accordion for a menu but it has a panel which is open automatically, I'm wondering how I can have it so no panels are open until it is clicked. This is a pure css menu but I can't figure out why it's open automatically.
body {background: #e0e3ec url(http://netcribe.com/example/bgnoise_lg.jpg) repeat top left;}
.ac-container{
width: 400px;
margin: 10px auto 30px auto;
}
.ac-container label{
font-family: 'Arial Narrow', Arial, sans-serif;
padding: 5px 20px;
position: relative;
z-index: 20;
display: block;
height: 30px;
cursor: pointer;
color: #777;
text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
line-height: 33px;
font-size: 19px;
background: -moz-linear-gradient(top, #ffffff 1%, #eaeaea 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffffff), color-stop(100%,#eaeaea));
background: -webkit-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
background: -o-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
background: -ms-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
background: linear-gradient(top, #ffffff 1%,#eaeaea 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eaeaea',GradientType=0 );
box-shadow:
0px 0px 0px 1px rgba(155,155,155,0.3),
1px 0px 0px 0px rgba(255,255,255,0.9) inset,
0px 2px 2px rgba(0,0,0,0.1);
}
}
.ac-container label:hover{
background: #fff;
}
.ac-container input:checked + label,
.ac-container input:checked + label:hover{
background: #c6e1ec;
color: #3d7489;
text-shadow: 0px 1px 1px rgba(255,255,255, 0.6);
box-shadow:
0px 0px 0px 1px rgba(155,155,155,0.3),
0px 2px 2px rgba(0,0,0,0.1);
}
.ac-container label:hover:after,
.ac-container input:checked + label:hover:after{
content: '';
position: absolute;
width: 24px;
height: 24px;
right: 13px;
top: 7px;
background: transparent url(http://netcribe.com/example/arrow_down.png) no-repeat center center;
}
.ac-container input:checked + label:hover:after {
background-image: url(http://netcribe.com/example/arrow_up.png);
}
.ac-container input{
display: none;
}
.ac-container article{
background: rgba(255, 255, 255, 0.5);
margin-top: -1px;
overflow: hidden;
height: 0px;
position: relative;
z-index: 10;
-webkit-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
-moz-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
-o-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
-ms-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
}
.ac-container input:checked ~ article {
-webkit-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
-moz-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
-o-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
-ms-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
box-shadow: 0px 0px 0px 1px rgba(155,155,155,0.3);
height: 100px;
}
.ac-container article p{
font-style: italic;
color: #777;
line-height: 23px;
font-size: 14px;
padding: 20px;
}
change <input id="ac-1" name="accordion-1" type="checkbox" checked />
to <input id="ac-1" name="accordion-1" type="checkbox" />
Remove the checked. It seems the accordion relies on these checkboxes being checked. Remove the checked and it won't open.
I have one problem about visibility. I have to create this DEMO from fiddle.
If you click my demo you can see there is a one image. When you hoverover mouse this image then bubble will open. But if you come with the mouse to the left of the image blank bubble opens again. How can I fix this problem ?
.balon
{
position: absolute;
width: 345px;
height: auto;
padding: 3px;
background: #FFFFFF;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
border: #d8dbdf solid 1px;
-webkit-box-shadow: -1px 1px 1px 0px rgba(216, 219, 223, 0.52);
-moz-box-shadow: -1px 1px 1px 0px rgba(216, 219, 223, 0.52);
box-shadow: -1px 1px 1px 0px rgba(216, 219, 223, 0.52);
visiblility: hidden;
opacity:0;
margin-left: -345px;
z-index:5;
-webkit-transition: all .3s ;
-moz-transition: all .3s ;
-ms-transition: all .3s ;
-o-transition: all .3s ;
transition: all .3s ;
}
.balon:after
{
content: '';
position: absolute;
border-style: solid;
border-width: 10px 0 10px 10px;
border-color: transparent #fff;
display: block;
width: 0;
z-index: 1;
right: -10px;
top: 16px;
}
.vizyon_bg:hover .balon
{
opacity:1;
visibility:visible;
z-index:5;
transition: opacity .5s linear .5s;
-webkit-transition: opacity .5s linear .5s;
-moz-transition: opacity .5s linear .5s;
-ms-transition: opacity .5s linear .5s;
}
Dude i found the solution! just replace your balon's CSS and you're done! you have wrong z-index :}
I've created JSFiddle for you! http://jsfiddle.net/9pgqc24c/
.balon
{
position: absolute;
width: 345px;
z-index:-99999;
height: auto;
padding: 3px;
background: #FFFFFF;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
border: #d8dbdf solid 1px;
-webkit-box-shadow: -1px 1px 1px 0px rgba(216, 219, 223, 0.52);
-moz-box-shadow: -1px 1px 1px 0px rgba(216, 219, 223, 0.52);
box-shadow: -1px 1px 1px 0px rgba(216, 219, 223, 0.52);
visiblility:hidden;
opacity:0;
margin-left:-345px;
z-index:-1;
-webkit-transition: all .3s ;
-moz-transition: all .3s ;
-ms-transition: all .3s ;
-o-transition: all .3s ;
transition: all .3s ;
}
i've got following problem:
when im using transform scale for hover the image shows judder.
Here my Code:
<div class="item">
</div>
.item {
background: transparent url("http://s14.directupload.net/images/141019/s3r8avxj.jpg") no-repeat 0 0 / 176px 176px;
width: 176px;
height: 176px;
display: inline-block;
font-family: Arial;
margin: 0px 10px 10px 0px;
border: 5px solid #fff;
-webkit-box-shadow: 0 0 2px 1px rgba(0,0,0,0.4);
box-shadow: 0 0 2px 1px rgba(0,0,0,0.4);
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s linear;
-ms-transition: all 0.3s linear;
-o-transition: all 0.3s linear;
transition: all 0.3s linear;
}
.item:hover {
transform: scale(1.05);
border: 5px solid #fff;
cursor: default;
}
Fullscreen view: http://jsfiddle.net/excsa15w/embedded/result/
Code: http://jsfiddle.net/excsa15w/
Is there a possibility to remove the judding?
Thanks in advance
Change property
background: transparent url("http://s14.directupload.net/images/141019/s3r8avxj.jpg") no-repeat 0 0 / 176px 176px;
To
background: transparent url("http://s14.directupload.net/images/141019/s3r8avxj.jpg") no-repeat;
jsfiddle
I have created a simple check-box switch, here is a JSFiddle: http://jsfiddle.net/aseVX as you have noticed, when you click the little circle jumps, i am trying to make it smoothly shift from left to right and right to left. I tried adding CSS transition and that didn't make it work. Any ideas of what I am doing wrong?
/*Checkbox Switch*/
.switch p, .switch label {
display: inline;
}
.switch label {
margin-left: 10px;
}
.switch label > span {
background-color: rgba(0, 0, 0, 0.1);
border: 1px solid #A6A6A6;
width: 50px;
height: 30px;
position: relative;
display: inline-block;
vertical-align: middle;
cursor: pointer;
border-radius: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
-webkit-transition: all .15s linear;
-moz-transition: all .15s linear;
-ms-transition: all .15s linear;
-o-transition: all .15s linear;
transition: all .15s linear;
}
.switch input[type="checkbox"]:checked + span {
background-color: #316C94;
border: 1px solid rgba(0, 0, 0, 0.4);
}
.switch span span {
background-color: #fff;
border: 1px solid #A6A6A6;
width: 24px;
height: 24px;
position: absolute;
top: 2px;
left: 2px;
cursor: pointer;
border-radius: 50px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
-webkit-transition: all .15s ease;
-moz-transition: all .15s ease;
-ms-transition: all .15s ease;
-o-transition: all .15s ease;
transition: all .15s ease;
}
.switch label > span:hover span {
width: 30px;
}
.switch input[type="checkbox"]:checked + span span {
right: 2px;
left: auto;
border: none;
}
/*Checkbox Switch > Disabled*/
.switch input[type="checkbox"]:disabled + span {
background-color: rgba(0, 0, 0, 0.1) !important;
border: 1px solid #A6A6A6 !important;
}
.switch input[type="checkbox"]:disabled + span span, .switch input[type="checkbox"]:disabled + span span:hover {
background-color: #fff !important;
border: 1px solid #A6A6A6 !important;
width: 24px !important;
}
As Adrift said in the comments, you cannot animate to a state of auto
But, since you said the width is set, you can animate to the left value that fits the width like so
.switch input[type="checkbox"]:checked + span span {
left: 23px;
border: none;
}
Demo
In addition I added a change the left position when the checkbox was checked and it was hovered
The prefixed versions of border-radius are not needed because -moz-border-radius was never a thing and browsers that don't support border-radius will not support transitions or anything like that either
Also, the !importants are not needed, if the selector is has a higher precedence or the same precedence but is further down the stylesheet, the styles will automatically be overridden. This is because CSS is a cascading language, meaning styles will apply over previous ones if they can. !important should try to be avoided as it causes issues when projects get large and such
I can never get my CSS transitions to work on mouse out/off hover. It works fine on hover but not the other way around.
.btn {
border: 1px solid #5a5350;
background: #FFF;
color: inherit !important;
padding: 3px 10px;
display: inline-block;
font-weight: bold;
text-transform: uppercase;
-webkit-transition: background 0.5s ease-in-out;
-moz-transition: background 0.5s ease-in-out;
-o-transition: background 0.5s ease-in-out;
transition: background 0.5s ease-in-out;
}
.btn:hover {
color: #FFF !important;
background: #f79e43;
border: 1px solid #f79e43;
}
What's the problem with my code?
Thanks