How are these check-marks being drawn?
Tags: css
Problem :
I was reading about pseudo-elements in the MDN reference site for CSS, and in the article about ::before
pseudo-element, they use a simple to-do list as an example. Its code is as follows:
HTML
<ul>
<li>Buy milk</li>
<li>Take the dog for a walk</li>
<li>Exercise</li>
<li>Write code</li>
<li>Play music</li>
<li>Relax</li>
</ul>
CSS
li {
list-style-type: none;
position: relative;
margin: 2px;
padding: 0.5em 0.5em 0.5em 2em;
background: lightgrey;
font-family: sans-serif;
}
li.done {
background: #CCFF99;
}
li.done::before {
content: '';
position: absolute;
border-color: #009933;
border-style: solid;
border-width: 0 0.3em 0.25em 0;
height: 1em;
top: 1.3em;
left: 0.6em;
margin-top: -1em;
transform: rotate(45deg);
width: 0.5em;
}
Javascript
var list = document.querySelector('ul');
list.addEventListener('click', function(ev) {
if( ev.target.tagName === 'LI') {
ev.target.classList.toggle('done');
}
}, false);
I get what the Javascript code does, and I was expecting that the check-mark would be images, but they're drawn by the CSS code. I can see where are the instructions about what and how to draw it, but I can't understand these instructions.
I also didn't know how to google about it (because I don't know the name of this technic in CSS), so I really got stuck here. How does it work?
Solution :
li.done::before { /* This creates a (pseudo) element that is (by default) placed before the content, but is hidden (by default). */
content: ''; /* This makes this (pseudo) element actually appear. */
position: absolute; /* This makes it not push the content or affect it in anyway and also makes it act as if it has some sort of display: inline-block; */
/* These create a right and bottom border and give a width and a height (width * 2) to this (pseudo) element, so you get a reversed L shape. */
border-color: #009933; /*
border-style: solid;
border-width: 0 0.3em 0.25em 0;
height: 1em;
width: 0.5em;
/* These position this (pseudo) element relatively to its real/owner element, the LI, since it has position: relative. */
top: 1.3em;
left: 0.6em;
margin-top: -1em;
/* This rotates this (pseudo) element. When you rotate a reversed L, it looks like a check mark. */
transform: rotate(45deg);
}
CSS Howto..
Simply change your CSS to care about what the class is... Change li:hover{ background-color: #111; } to .active:hover{ background-color: #111; } ...
You could use absolute positionned DIV for your "boxes" and use two DIV for the vertical and horizontal lines. Something (untested) like : CSS: .box { position:relative; } .box-end {...
In order to have opacity on a boarder, you need to use the RGBA color scheme, otherwise the entire element takes on the opacity setting. border-color:rgba(255,0,0,.1) IE7 does not support...
echo substr(strip_tags($row['content']),0,50) Then when they 'get more' do not run strip_tags() Updated.....
If you insert a div that include your link and image and set the height to your div you can align your text try this: <div class="one_fourth"> <div class="img"> <a...
if it is only for visual effect , you maybe have an option with transform:scale(3); to to zoom three times your element. DEMO To avoid scaling inside content, do a...
You need to create a mailto link, using the href attribute. Like <a class="btn btn-primary btn-lg" href="mailto:test@example.com" target="_blank" role="button">Submit Your CV</a> It also depends what the users uses as default...
In your css, you've used display: inline-block; and float: left; together. That is not necessary. They kind of have similar effect. Removing float: left solves the problem... .fourth_section .col {...
instead of border-left you could use the :before or :after pseudo elements and style that to look how you want .left-border-red:before { content:''; border-left: 5px solid red; height: 100%; width:...
When the DOM is finished loading you can add your code in the $(document).ready() function. Remove the onclick from here: <input type="submit" name="submit" value="Submit" onClick="PopUp()" /> Try this: $(document).ready(function(){ setTimeout(function(){...
Live demo http://tinkerbin.com/RrRtqfVf Do this one HTML <ul> <li>Hello</li> <li>Hello</li> <li>Hello</li> <li>Hello</li> <li>Hello</li> <li>Hello</li> <li>Hello</li> </ul> Css ul{ list-style:none; } li{ position:relative;...
Your demo is lil weird but anyways, if you want to deduct 10em from 100% then use calc() property like #top { width: 100%; /* You won't need this */...
Try using rowLines: False to remove row line styling For example: https://fiddle.sencha.com/#fiddle/11s7...
Pure CSS Solution Here's the jsFiddle example with comparison to original image and the CSS: span.tag { margin:4px 5px; position:relative; border-radius:5px; background:red; display:inline-block; padding:.6em 4.5em; text-align:center; } span.tag-gray { background:...
Twitter implements this with a simple CSS3 box-shadow: input:focus { box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1) inset, 0 0 10px rgba(255,...
you can set in JQuery by below Line of Code, Here is DEMO $('#container').css('-webkit-mask-box-image',"url('masks/4.png')") ...
You need to figure out in which column each of the events should be before you can determine their width or left-position. To do this, you need to also store...
You can have raw access to style sheet tags, that's the best you can do, you can then parse the text for the information you're looking for with something like...
But there is the PHP that is confusing me. PHP is simply printing the $activelocation variable/string out to your output (HTML). The problem is that $activelocation could be anything....
There isn't a way using text-decoration since that style is the decoration added to the text of that element. You could use multiple spaces ( ) but it'd be sloppy and...
Try this fiddle: http://jsfiddle.net/aKh5x/ HTML: <div class="sizeit"> <select id="SelectUrgency" class="invisible"> <option value="3">Non Urgent</option> <option value="2">Urgent</option> <option value="1">System Down</option> </select>...
It's a bit hard to understand from your post but I think you're trying to get your images to fill in the available space like the example site you provided...
this should give desired effect: html <div class="group"> <div class="text"> Your text here </div> <div class="images"> <img src="image1.jpg"> <img src="image2.jpg"> </div> </div> css // this is the clear fix, so...
The body tag has a default margin property. Use the following CSS code to get rid of the default margin: body { margin:0; } ...
HTML <div><img src=".jpg" width="110" />text</div> . . . <div><img src=".jpg" width="110" />text</div> CSS div{ width:160px; border:1px solid grey; text-align:center; min-height:150px; height:auto; vertical-align:middle; padding:8px; float:left } img{display:block; margin:0 auto} DEMO Resize...
Try this: Remove the class='row_{$row}' from td and put it to tr tag Then replace this part of your css: /**/ .row_0 { background-color: #424140; padding: 3px 5px 3px 5px;...
Why not just use CSS3 transitions? No JS at all. The fading effect wouldn't work in IE, but it's a much cleaner way of implementing. And it degrades just fine....
<style> div{ font-family:"Courier New", Courier, monospace; margin-left: 65px; } span{ margin-left: -65px; } </style> Hopefully you can put a <br /> at the end of each linebreak. If you have...
Here is a solution using JQuery Provided you add a CssClass named chk to asp:checkbox <asp:CheckBox ID="chkSelect" runat="server" CssClass="chk" /> Here is the script $(document).ready(function () { $(".chk :checkbox").live("click", function...
What you need is to add the transition property on the right element and to change the origin of the transform. Add this : #slow-container2 { transition:all .3s linear; transform-origin:bottom...