Tag: css

How can you get the CSS pixel / device pixel ratio?

I want to find the ratio between CSS pixels and device pixels. Edit: I should have realized that this is just zoom level. I’ve added an answer to the canonical reference on zoom levels. CSS pixels are the unit we use for almost everything–it’s what element.style.width, element.clientWidth, element.offsetWidth etc. mean. Device pixels are the pixels […]

Add inline style using Javascript

I’m attempting to add this code to a dynamically created div element style = “width:330px;float:left;” The code in which creates the dynamic div is var nFilter = document.createElement(‘div’); nFilter.className = ‘well’; nFilter.innerHTML = ‘<label>’ + sSearchStr + ‘</label>’; My idea is to add the style after < div class=”well” but i don’t know how i’d […]

word wrap in css / js

I’m looking for a cross-browser way of wrapping long portions of text that have no breaking spaces (e.g. long URLs) inside of divs with pre-determined widths. Here are some solutions I’ve found around the web and why they don’t work for me: overflow : hidden / auto / scroll – I need the entire text […]

Wanted: offline IDE for developing Html / JavaScript on Android tablet

In have a Motorola Xoom tablet and I would like to use it to develop some small Html / Css / JavaScript / jQuery applications. **Does anyone know a good IDE to do web development on Android? I only need the IDE for: html, css, jQuery / JavaScript (other languages would be cool though). Clarification: […]

Change :hover CSS properties with JavaScript

I need to find a way to change CSS :hover properties using JavaScript. For example, suppose I have this HTML code: <table> <tr> <td>Hover 1</td> <td>Hover 2</td> </tr> </table> And the following CSS code: table td:hover { background:#ff0000; } I would like to use JavaScript to change the <td> hover properties to, say, background:#00ff00. know […]

What are some good css and js minimizers for production code?

I’m looking for some applications or websites that minimize css and js files. Ideally, they could batch them all or if not, one at a time.

Extract the current DOM and print it as a string, with styles intact

I’d like to be able to take my DOM, as is, and convert it to a string. Let’s say I open up the inspector and make a change to the margin-left property of a particular element. That change should be reflected in my string. The function should properly take all the styles currently applied to […]

Where should I put the CSS and Javascript code in an HTML webpage?

While designing a webpage, where should I put the following code? <link rel=stylesheet type=”text/css” href=”css/layout.css”> Should I put it in the <head> or should I put it in the <body>? Please clarify the following questions: What difference does it make if I put it in <head> or anywhere else around the HTML code? What if […]

How to create a custom scrollbar on a div (Facebook style)

I’m wonder how the custom scrollbar on Facebook has been made. Is it only css or some javascript as well? If yes can i have an idea of what the code looks like? This question is specific to Facebook scrollbar style and not how to simply have a custom scrollbar

Can you control GIF animation with Javascript?

Is it possible to use javascript to control which frame of a GIF image is showing and/or stop the animation. I want to be able to load a GIF with several frames and only show one of them. I know I could do it with lots of separate images, but if I can do what […]