CSS “margin: 0 auto” not centering

It is working. The problem is you’re centering a div, which is a block-level element by default, and which therefore occupies 100% width of its parent (body, in this case). So there’s no space to move horizontally, hence no space to center. For an illustration see this revised demo, which has an added border around … Read more

How to get current screen width in CSS?

I use the following CSS code for formatting when screen width is less than 480px, and it works well. I would like to get the current width for calculation to use zoom like it follows:

How can I move this text up using CSS?

Move s1-text and s2-text inside the .hero class: Add position: relative; to .hero class, so that the absolutely positioned s1-text and s2-text stay inside hero: And then add absolute positioning to the texts like this: Working Demo On Codepen

How do you give iframe 100% height

You can do it with CSS: Be aware that this will by default place it in the upper-left corner of the page, but I guess that is what you want to achieve. You can position with the left,right, top and bottom CSS properties.

Partial render in HTML/JavaScript

If you’re just using plain HTML and Javascript, you could include jQuery and use an AJAX request to load the contend of another HTML page in your main page. Have a look at the jQuery ‘load()’ function here: http://api.jquery.com/load/ Assuming your have the following html: your usage would look something like this:

height style property doesn’t work in div elements

You cannot set height and width for elements with display:inline;. Use display:inline-block; instead. From the CSS2 spec: 10.6.1 Inline, non-replaced elements The height property does not apply. The height of the content area should be based on the font, but this specification does not specify how. A UA may, e.g., use the em-box or the maximum ascender and descender of the font. (The latter would … Read more