How to change elements opacity based on if checkbox is or is not checked with CSS only?
Tags: jquery,html,css,checkbox,checked
Problem :
I know that I could use .is(':checked')
with jQuery, but is there a CSS way? I kind of would like to make this #navbar-checkbox:checked #mobile-nav { display: block; }
bit of code work, as I know I could do something similar with :hover
, but is there a way to do it with :checked
?
So the full markup:
CSS
#mobile-nav { display: none; }
#navbar-checkbox:checked #mobile-nav { display: block; }
That's really all I want.
Solution :
It would be helpful to see your markup, but it is possible.
For example, this assumes a checkbox that is adjacent (specified by the +
combinator) to the element you want to target:
.test {
background-color: red;
color: white;
}
input[type="checkbox"]:checked + .test { opacity: 0.5; }
<input type="checkbox">
<div class="test">Test</div>
CSS Howto..
If I understand correctly, you need to add the same text under every image. You can achieve this only with css by using the following code: .product_des1:after { content: "My...
Keeping Bootstrap's navbar-top-fixed from zooming on mobiles The final result: On mobile devices only, is possible to calculate the zoom factor as the ratio of window.innerWidth and the screen width,...
I would do the following. Use absolute positioning to place .controls_prev to the left and .controls_next to the right. Keep .controls_toggle in regular flow and use margin: 0 auto to...
<div class="alert alert-warning alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert"> <span aria-hidden="true">×</span><span class="sr-only">Close</span> </button> <strong>Warning!</strong> Better check yourself,...
1) You can add a class for that purpose which assigns all the properties. 2) If you try it your way then, Javascript will reassign the property 3 times and...
After the Zurb copyright comment add: @import {url(fonts.googleapis.com/css?family=Open+Sans); } Then within the Foundation code find each instance of: font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif; and change it to: font-family:"Open Sans","Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif; I've...
You could try something like the following If you set something in your CSS file called TextFormat. var css:CSSStyleDeclaration = StyleManager.getStyleDeclaration("TextFormat") yourComponent.setStyle("textAlign", getStyle("headerTextAlign")); yourComponent.setStyle("fontFamily", getStyle("fontFamily")); This should do what...
Here you go: http://jsfiddle.net/ahallicks/8gApb/2/ changed the display property to opacity and set it to 0 #nav > ul { opacity: 0; } And then added transition to that too: transition:...
Try adding these rules: .cities-main{ padding: 0; text-align: center; } .cities-main > li:last-child{ margin-right: 0; } By doing so, the last link won’t break into a new line due to...
You haven't given your second canvas any styles. Make them both inline-block, they will be next to eachother. http://jsbin.com/vabevadoto/edit?html,css,js,output I added a red outline so you could see the second...
Like mariusnn said, take those styles off .item-thumbnail and put them directly on the img and see if you like that effect better.
try this .well .btn-inverse { border-top:none!important; } .btn { box-shadow:none!important; } demo: http://jsfiddle.net/H6zK7/...
CSS #sentbox thead tr th:nth-of-type(2){ \\css goes here } :nth-of-type() selector matches every element that is the nth child, of a particular type, of its parent. DEMO #sentbox thead tr...
try this. in the url in app calling the xhtml iframe put a query string, so in app 1 use display.xhtml?style=a and app 2 use display.xhtml?style=b then in display.xhtml use...
You now got: var type = $(this).attr('data-type'); Since the function is called on the <select>, you select the data-type attribute of the <select> (which is defined), and not from the...
Give your <img> the opposite skew of your div by adding transform : skewY(2deg);. This will only skew the bottom of your image. CSS img { -webkit-transform: skewY(2deg); -moz-transform: skewY(2deg);...
If you whant to get gwt-TextBox-error style name on widget, you need set box.setStylePrimaryName("gwt-TextBox"); - it's by default. And when error occured use box.setStyleDependentName("error", true); HTML will be class="gwt-TextBox gwt-TextBox-error"....
In the Chrome dev tools, in the right hand column (where CSS is shown in the Elements panel), the first section is called "Computed Style". If you deselect "show inherited",...
You can accomplish this by using a combination of HTML, CSS and jQuery. See the code I whipped up here to create a checkbox from an <a> tag and style...
The trick here is setting the space between the images and setting the values of the background-position in CSS. Below is the actual sprite of the aforementioned website. http://www.chaudharygroup.com/templates/cg/images/social-network-icons.jpg And...
If you want to fade out the text at the same speed as the image here are two options Image Hover Method (jsfiddle) This method is similar to what you...
If you are willing to use the calc() CSS function, this problem is relatively easy to solve: #main{ width: 500px; display: inline-block; } #left, #right{ width: calc(50% - 250px); display:...
The globe needs to be a transparent png, and then style the box ignoring the image, padding and a border to get the desired look. Then, whack position: relative on...
DEMO .timeline-panel { background-color:red!important; } .timeline > li > .timeline-panel:after { border-left:14px solid red!important; border-right: 0 solid red!important; } .timeline > li.timeline-inverted > .timeline-panel:after { border-left:14px solid #fff!important; border-right-width: 14px!important;...
If you view the page source, you will see this script. <script type="text/javascript" language="javascript" src="/js/jquery.carouFredSel.js"></script> You can also see the javascript(jQuery) code its calling $(function() { var _direction = 'left';...
Under Mozilla (as documented here: https://developer.mozilla.org/en-US/docs/CSS/Privacy_and_the_:visited_selector) and Chromium (possibly the same for Chrome), empirically verified: You will still be able to visually style visited links, but there are now limits...
Bootstrap has a helper class called clearfix that you should put in an empty div after every 4 columns in md mode, after every 3 columns in sm mode, and...
Your options are breaking because you're not making the width wide enough. A quick fix is to use non breaking spaces ( ). You can either hardcode them of add them...
That worked because if you notice on the code in the theme preview it says : <body class="**home** page page-id-17 page-template-default res1170" data-twttr-rendered="true"> it would also work if you used...
You can use nth-child. For more details see here: https://css-tricks.com/how-nth-child-works/ To add more detail, badically you would do something like this: p:nth-child(2) { } Or apply it to a div...