Is it possible to set the equivalent of a src attribute of an img tag in CSS?

Use content:url(“image.jpg”). Full working solution (Live Demo): <!doctype html> <style> .MyClass123{ content:url(“http://imgur.com/SZ8Cm.jpg”); } </style> <img class=”MyClass123″/> Tested and working: Chrome 14.0.835.163 Safari 4.0.5 Opera 10.6 Firefox 100 & newer Tested and Not working: FireFox 40.0.2 (observing Developer Network Tools, you can see that the URL loads, but the image is not displayed) Internet Explorer 11.0.9600.17905 … Read more

What is the difference between display: inline and display: inline-block?

A visual answer Imagine a <span> element inside a <div>. If you give the <span> element a height of 100px and a red border for example, it will look like this with display: inline display: inline-block display: block Code: http://jsfiddle.net/Mta2b/ Elements with display:inline-block are like display:inline elements, but they can have a width and a … Read more

How to affect other elements when one element is hovered

If the cube is directly inside the container: #container:hover > #cube { background-color: yellow; } If cube is next to (after containers closing tag) the container: #container:hover + #cube { background-color: yellow; } If the cube is somewhere inside the container: #container:hover #cube { background-color: yellow; } If the cube is a sibling of the … Read more

Convert an image to grayscale in HTML/CSS

Support for CSS filters has landed in Webkit. So we now have a cross-browser solution. img { filter: gray; /* IE6-9 */ -webkit-filter: grayscale(1); /* Google Chrome, Safari 6+ & Opera 15+ */ filter: grayscale(1); /* Microsoft Edge and Firefox 35+ */ } /* Disable grayscale on hover */ img:hover { -webkit-filter: grayscale(0); filter: none; … Read more

Position absolute but relative to parent

#father { position: relative; } #son1 { position: absolute; top: 0; } #son2 { position: absolute; bottom: 0; } This works because position: absolute means something like “use top, right, bottom, left to position yourself in relation to the nearest ancestor who has position: absolute or position: relative.” So we make #father have position: relative, … Read more

Why not use tables for layout in HTML? [closed]

I’m going to go through your arguments one after another and try to show the errors in them. It’s good to separate content from layout But this is a fallacious argument; Cliché Thinking. It’s not fallacious at all because HTML was designed intentionally. Misuse of an element might not be completely out of question (after … Read more

Making a div vertically scrollable using CSS

You have it covered aside from using the wrong property. The scrollbar can be triggered with any property overflow, overflow-x, or overflow-y and each can be set to any of visible, hidden, scroll, auto, or inherit. You are currently looking at these two: auto – This value will look at the width and height of … Read more

How to force child div to be 100% of parent div’s height without specifying parent’s height?

For the parent: display: flex; You should add some prefixes, http://css-tricks.com/using-flexbox/. As @Adam Garner noted, align-items: stretch; is not needed. Its usage is also for parent, not children. If you want to define children stretching, you use align-self. .parent { background: red; padding: 10px; display:flex; } .other-child { width: 100px; background: yellow; height: 150px; padding: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)