Responsive pseudo text [duplicate] - css

This question already has answers here:
Responsive font size in CSS
(33 answers)
Closed 5 years ago.
I'm trying to add text in a pseudo element :before the body. It seems however I am forced to set the font-size which means it isn't responsive.
How can I force the content:'404' to be responsive when changing the browser dimensions? I'm I absolutely limited to SVG images?
Result I'm looking for is the 404 text behind content:
.

have you tried with "vw" - Viewport-percentage lengths
body::before {
content: "404";
font-size: 50vw;
position: absolute;
left: 50%;
transform: translate(-50%, -25px);
}

Related

inline-block moving down on page [duplicate]

This question already has answers here:
Why is this inline-block element pushed downward?
(8 answers)
Missalignment with inline-block (other elements pushed down)
(2 answers)
CSS inline-block issue - element being pushed down [duplicate]
(3 answers)
Closed 3 months ago.
I am participating in a CSS class on Udemy. Unfortunately I got no answers on thier internal discord site, so I am trying here.
This is a question about the display of some elements. What I don't understand is that first div element is moving down on the page, because I wrote the text "Hey you" in it. It shouldn't move down in my opinion, it should stay on the top of the page inline with the other two elements.
Here is the html and CSS:
div {
height: 200px;
width: 200px;
background-color: olivedrab;
border: 5px solid black;
display: inline-block;
margin: 50px;
}
<div>Hey you</div>
<div></div>
<div></div>
First div moving down
I have tried to give the first div an id:
<div id="first_div">Hey you</div>
And give that id a position of absolute:
#first_div {
position: absolute;
}
But it doesn't really work since the absolute value of the position property removes the element from the document flow, and thereby places it on top of the second element, so only two out of the three divs is showing, so no fix really!
Divs are now incorrectly stacked

CSS translate percentage meaning [duplicate]

This question already has answers here:
Transform: translate(-50%, -50%)
(2 answers)
Closed 6 months ago.
When there is css style like below:
.text-box {
width: 90%;
color: #fff;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Where is translate's percentage based on? The body? or the parent div? -50% of what?
Actually this percentage based on size of "reference box" which defined by transform-box property. You can see details here and here.
To put it simple, by default this based on size (width/height) of element which class applied to.
According to the spec and MDN, it's based on the transform-box property.
The spec for transform-box outlines the values and what that means. The default in the browser is still content-box which is defined as,
content-box
Uses the content box as reference box. The reference box of a table is the border box of its table wrapper box, not its table box.
So lots of words to say it's based on the size of the element assigned the class.

Why does the parent element have additional space when child pseudo element set to display inline-block? [duplicate]

This question already has answers here:
Image inside div has extra space below the image
(10 answers)
Why is this inline-block element pushed downward?
(8 answers)
Closed 3 years ago.
Example:
https://codepen.io/229075284/pen/aboQVXZ
.outer{
background-color: pink;
}
.outer::after{
content:'';
background-color: red;
display: inline-block;
font-size: 0;
line-height: 0;
overflow: hidden;
height: 0;
/* display: table; */
}
.inner{
background-color: blue;
height: 300px;
}
<div class="outer">
<div class="inner"></div>
</div>
When I set display of outer::after to inline-block,the outer will have some extra space marked as pink, even if set font-size and line-height to 0. However, when I set display to table,the extra space disappears.
So I am wondering why the extra space appears?
I checked your codepen. It is a combination of both display: inline-block and content: "" on the ::after pseudo element. You are basically telling the browser that right after the outer element you want to reserve an element's place in the DOM.
You could see that if you remove the content: "" although you are using inline-block the extra pseudo div after the .outer element would disappear. That is because although you stated a certain display mode you practically have no content in this element and the browser ignores your element because it has no fixed size in pixels and no actual content within it.
The reason .outer is growing is that its height is set to auto in default, if you would give it a fixed height in pixels it might not show the spare div.
Your question has nothing to do with line-height or `overflow'.
Me personally I prefer not to use pseudo-classes like ::after and ::before in production. I prefer using regular divs and have my code more readable and understandable by other developers, anyway I hope I helped out. Feel free to discuss further if you have more questions.

Reducing background image opacity in one div [duplicate]

This question already has answers here:
Set opacity of background image without affecting child elements
(15 answers)
Closed 7 years ago.
I need to control background image opacity. I tried to use Opacity option, but it effects all header elements.
Can I reduce opacity of background image in this code?
.header-container {
width: 100%;
background: url(/images/header-bg6.png) repeat;
display: block;
If you want this then you have to change the image to PNG width transparent image
or
You can take a div which have position: absolute; before the header-container which will have the same height as header-container, then apply the background-image and opacity: 0.2; filter: alpha(opacity=20);
I hope I will helps you.

IE 8 : Mysterious Box coming around Radio Button [duplicate]

This question already has answers here:
Hidden radio button but box around it in ie8
(3 answers)
Closed 8 years ago.
In the below image - you see a mysterious box coming around Radio Button.
Any ideas what can be done ?
Below is the styling applied :
.inline-radio {
padding-top: 0px;
}
.inline-radio input[type="radio"] {
position: absolute;
opacity: 0;
}
Just from looking at your image, it looks like it has been ripped out of the layout as a result of position: absolute. One thing you could do, is display: inline instead. Not sure there is much to gain from absolute positioning without a top and left property.

Resources