Retrieve the position (X,Y) of an HTML element

The correct approach is to use element.getBoundingClientRect(): var rect = element.getBoundingClientRect(); console.log(rect.top, rect.right, rect.bottom, rect.left); Internet Explorer has supported this since as long as you are likely to care about and it was finally standardized in CSSOM Views. All other browsers adopted it a long time ago. Some browsers also return height and width properties, though … Read more

Vertically align text next to an image?

Actually, in this case it’s quite simple: apply the vertical align to the image. Since it’s all in one line, it’s really the image you want aligned, not the text. <!– moved “vertical-align:middle” style from span to img –> <div> <img style=”vertical-align:middle” src=”https://via.placeholder.com/60×60″ alt=”A grey image showing text 60 x 60″> <span style=””>Works.</span> </div> Tested … Read more

What’s the difference between SCSS and Sass?

Sass is a CSS pre-processor with syntax advancements. Style sheets in the advanced syntax are processed by the program, and turned into regular CSS style sheets. However, they do not extend the CSS standard itself. CSS variables are supported and can be utilized but not as well as pre-processor variables. For the difference between SCSS … Read more

How do I give text or an image a transparent background using CSS?

Either use a semi-transparent PNG or SVG image or use CSS: background-color: rgba(255, 0, 0, 0.5); Here’s an article from css3.info, Opacity, RGBA and compromise (2007-06-03). Beware that the text still needs sufficient contrast with the background, once the underlying background shines through. <p style=”background-color: rgba(255, 0, 0, 0.5);”> <span>Hello, World!</span> </p>

Make a div fill the height of the remaining screen space

2015 update: the flexbox approach There are two other answers briefly mentioning flexbox; however, that was more than two years ago, and they don’t provide any examples. The specification for flexbox has definitely settled now. Note: Though CSS Flexible Boxes Layout specification is at the Candidate Recommendation stage, not all browsers have implemented it. WebKit … Read more

When to use margin vs padding in CSS [closed]

TL;DR: By default I use margin everywhere, except when I have a border or background and want to increase the space inside that visible box. To me, the biggest difference between padding and margin is that vertical margins auto-collapse, and padding doesn’t. Consider two elements one above the other each with padding of 1em. This … Read more

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