Skip to content

Tag: css

Javascript zoom in/out to mouse x/y coordinates

I managed to make the mouse dragging to scroll the div, but the zooming in/out with the mouse is not complete. It works, but I would like for the mouse pointer to hold the image in that position and scale it at the same time, like so: I need to use scrollBy() to return the scrolling back to the previous

Shortest way to add CSS rules with vanilla JS

I’m working on a library that I’m trying to keep it below 1KB. Which I’m already very close to my limits. I need to add a css rule to control show hide behaviour. HTML page does not have any style tags. This will be only rule I need. I can only add it with pure JS. I do not want

Can’t edit input text field after window.alert()

I’ve got this Electron app (using NodeJS, Bootstrap, AngularJS) with some text input fields that can be edited. I have a button that triggers a window.alert() After it has been triggered, the text input fields are no longer editable. Clicking on other elements of the app changes nothing. Clicking on ano…

Make backgroundimage clickable in a CSS grid

I have a div tag with a background image. How is it possible to make that div tag into a hyperlink on larger and smaller screens? Is it something like this?: onclick=’window.location.href=”https://www.google.com”‘. HTML: CSS: Answer If you use jQuery: I think that if you have different…

DOMException: Failed to execute styleSheet.insertRule

I am attempting to insert a rule into a stylesheet. The rule is valid (I think) and is taken from normalize.css (https://github.com/necolas/normalize.css/blob/master/normalize.css#L206-L212) my code is: Chrome (75.0.3770.100) throws the error: The code above is used to insert other rules and works fine. It&#8…

Move large image inside smaller visible container

I am trying to do something basic (beginner in programming). I try to take a large image and a smaller container, and move the image up or down inside while the user scrolls. So you can . Move the yellow up or down while the user can see the red in the same position (kept in doc flow). If i

New line string from javascript

I cant do new line from javascript, I tried to do that with n, but nothing. Answer Apparently you are pretty new in javascript. You should use <br> instead. n new line for console outputs. Also you should use innerHTML instead of textContent. With textContent Console example: