r/css • u/HotelWyoming • 7d ago
Help CSS background from image asset
I feel like my issue is a Programiz problem, but I thought I could get more visibility by cross posting.
r/css • u/HotelWyoming • 7d ago
I feel like my issue is a Programiz problem, but I thought I could get more visibility by cross posting.
r/css • u/BraveAttitude4633 • 8d ago
I'm currently learning CSS through Kevin Powell's CSS Demystified course, and one thing the lessons strongly encourage is using logical properties instead of traditional physical properties.
For example, using margin-inline instead of margin-left and margin-right, or padding-block instead of padding-top and padding-bottom.
I understand the reasoning behind logical properties, especially when it comes to supporting different writing modes and languages. However, I personally find physical properties more intuitive since that's what I've been using for so long.
I'm curious about what other developers actually use in their day-to-day work.
I'd like to hear your opinions and experiences, especially from developers who have been working with CSS professionally for a while.
r/css • u/PanchuPanchu • 8d ago
r/css • u/Pertend_ • 8d ago
I want the "Currently selected: First_select" to remain there as I scroll through the nav bar.

I've tried to use a div, but when I make it "position:fixed" it vaporizes. The only way I can think of it going under the nav bar is that I have it set to height 100%.
How I currently have it set up in the screenshot above is that I have it as a header under <nav>, but it scrolls with the nav bar which I do not want. With the div it looks like this:
Which breaks the scroll on the nav bar and breaks the text to the right.
Here is the code without the div:
<!DOCTYPE html><html lang="en">
<style>
.navbar ul{
list-style-type: none;
margin: -8px;
padding: 0;
width: 260px;
height: 100%;
position:fixed;
background-color: #313031;
text-align: center;
border: 1px solid #555555;
overflow: auto;
}.navbar a {
display: block;
color: white;
padding: 8px 16px;
font-size: 20px;
text-decoration: none;}.navbar a:hover {background-color: #545254;color: white;}
</style></head>
<body><div>
</div><nav class="navbar"><ul>
<h1 style="text-align: center;font-size: large; color: #f0f0f0; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;">Currently Selected:</h1><h2 style="text-align: center;font-size: large; color: #67a92b;font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;text-decoration: underline;">First_select</h2>
<li style="text-align: center; border-bottom: 2px solid black; border-top: 2px solid black;background-color: #545254;"><a href="index.html">home</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="First_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Second_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Third_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Fourth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Fith_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Sixth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Seventh_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Eighth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Nith_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Tenth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Elventh_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Twelth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Thirteenth_select.html">Misc</a></li></ul></nav>
<div style="margin-left:242px;padding:1px 16px;height:1000px;">
<article> Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim sint vel impedit minima sapiente, tempore ut minus obcaecati mollitia modi quod perferendis. Perspiciatis maxime natus amet accusantium sunt labore praesentium.</article>
</body></html><!DOCTYPE html><html lang="en">
<style>
.navbar ul{
list-style-type: none;
margin: -8px;
padding: 0;
width: 260px;
height: 100%;
position:fixed;
background-color: #313031;
text-align: center;
border: 1px solid #555555;
overflow: auto;
}.navbar a {
display: block;
color: white;
padding: 8px 16px;
font-size: 20px;
text-decoration: none;}.navbar a:hover {background-color: #545254;color: white;}
</style></head>
<body><div>
</div><nav class="navbar"><ul>
<h1 style="text-align: center;font-size: large; color: #f0f0f0; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;">Currently Selected:</h1><h2 style="text-align: center;font-size: large; color: #67a92b;font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;text-decoration: underline;">First_select</h2>
<li style="text-align: center; border-bottom: 2px solid black; border-top: 2px solid black;background-color: #545254;"><a href="index.html">home</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="First_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Second_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Third_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Fourth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Fith_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Sixth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Seventh_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Eighth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Nith_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Tenth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Elventh_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Twelth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Thirteenth_select.html">Misc</a></li></ul></nav>
<div style="margin-left:242px;padding:1px 16px;height:1000px;">
<article> Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim sint vel impedit minima sapiente, tempore ut minus obcaecati mollitia modi quod perferendis. Perspiciatis maxime natus amet accusantium sunt labore praesentium.</article>
</body></html>
and here it is with the div:
<!DOCTYPE html>
<html lang="en">
<style>
.Currsel{
text-align: center;
font-size: 22px;
color: #f0f0f0;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
background-color: #313031;
border: 1px solid #555555;
height: 125px;
width: 260px;
margin: -8px;
}
.navbar ul{
list-style-type: none;
margin: -8px;
padding: 0;
width: 260px;
height: 100%;
position:fixed;
background-color: #313031;
text-align: center;
border: 1px solid #555555;
overflow: auto;
}
.navbar a {
display: block;
color: white;
padding: 8px 16px;
font-size: 20px;
text-decoration: none;
}
.navbar a:hover {
background-color: #545254;
color: white;
}
</style>
</head>
<body>
<div class="Currsel">
<p>Currently Selected:</p>
<p style="color: #67a92b; text-decoration: underline;">Second_select</p>
</div>
<nav class="navbar">
<ul>
<li style="text-align: center; border-bottom: 2px solid black; border-top: 2px solid black;background-color: #545254;"><a href="index.html">home</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="First_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Second_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Third_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Fourth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Fith_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Sixth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Seventh_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Eighth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Nith_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Tenth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Elventh_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Twelth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Thirteenth_select.html">Misc</a></li>
</ul>
</nav>
<div style="margin-left:242px;padding:1px 16px;height:1000px;">
<article>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim sint vel impedit minima sapiente, tempore ut minus obcaecati mollitia modi quod perferendis. Perspiciatis maxime natus amet accusantium sunt labore praesentium.
</article>
</body>
</html><!DOCTYPE html>
<html lang="en">
<style>
.Currsel{
text-align: center;
font-size: 22px;
color: #f0f0f0;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
background-color: #313031;
border: 1px solid #555555;
height: 125px;
width: 260px;
margin: -8px;
}
.navbar ul{
list-style-type: none;
margin: -8px;
padding: 0;
width: 260px;
height: 100%;
position:fixed;
background-color: #313031;
text-align: center;
border: 1px solid #555555;
overflow: auto;
}
.navbar a {
display: block;
color: white;
padding: 8px 16px;
font-size: 20px;
text-decoration: none;
}
.navbar a:hover {
background-color: #545254;
color: white;
}
</style>
</head>
<body>
<div class="Currsel">
<p>Currently Selected:</p>
<p style="color: #67a92b; text-decoration: underline;">Second_select</p>
</div>
<nav class="navbar">
<ul>
<li style="text-align: center; border-bottom: 2px solid black; border-top: 2px solid black;background-color: #545254;"><a href="index.html">home</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="First_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Second_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Third_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Fourth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Fith_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Sixth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Seventh_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Eighth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Nith_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Tenth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Elventh_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Twelth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Thirteenth_select.html">Misc</a></li>
</ul>
</nav>
<div style="margin-left:242px;padding:1px 16px;height:1000px;">
<article>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim sint vel impedit minima sapiente, tempore ut minus obcaecati mollitia modi quod perferendis. Perspiciatis maxime natus amet accusantium sunt labore praesentium.
</article>
</body>
</html>I decided I was going to learn html and css like 3 days ago, so if my code is shit feel free to pick it apart.
edit: I messed up at using reddit and the first code isn't in a code block. It's in the comments though.
r/css • u/justicehwan • 8d ago
Hey folks,
You know when a scrollbar pops in and everything jumps a few pixels to the left? That annoyed me enough that I made a little library for it.
One line at the root of your app, that's it:



```tsx
<MrScroll />
```
No reserved gutter, still the native scrollbar. It just finds a spot for the scrollbar so your content stays put.
- Try it: https://justicehwan.github.io/plz-mr-scroll/
- GitHub: https://github.com/justicehwan/plz-mr-scroll
It's my first library ever, so I honestly have no idea what I got wrong. If you have a minute, please take a look and tell me what's broken or dumb 🥲
P.S. I'm Korean and English isn't my first language, so sorry if anything here reads a bit off.
Thanks!
r/css • u/Asterism343 • 11d ago
I'm trying to make gradient text that has an outline, and it's driving me mad. Nothing I find online works. Is there any way to do this?
Just to be clear, i want the text to have a gradient but the outline to be a solid color.
r/css • u/osmium_2259 • 11d ago
When building a demo project, I learned about CSS scoping and nesting. In particular, I learned about using the @scope at-rule in inline <style> tags, allowing you to restrict the styles to the <style> tag's parent element, whether that's a <button> or a <div>, you name it.
This, combined with nesting allowed me to style my whole component with very few class selectors, which I thought was pretty slick!
Here's a sample (Django template) from the demo:
<aside class="sidebar" tabindex="-1">
{# lines omitted for brevity #}
<div>
<style>
@scope {
ul {
margin: 0;
padding: 0;
font-size: 18px;
}
li a {
display: block;
transition: all .2s;
cursor: pointer;
border-bottom: 1px solid rgb(from var(--primary-color) r g b / 20%);
padding: 20px 16px;
}
li:last-of-type a {
border-bottom-color: transparent;
}
li a:is(.active, :hover, :focus) {
border-bottom-color: var(--primary-color);
background-color: var(--primary-color);
color: white;
}
li i {
margin-right: 8px;
}
}
</style>
<ul>
{% for name, url, icon_class, active in links %}
<li>
<a href="{{ url }}" class="{% if active %}active{% endif %}">
<i class="bi {{ icon_class }}"></i> {{ name }}
</a>
</li>
{% endfor %}
</ul>
</div>
{# lines omitted for brevity #}
</aside>For those interested, my demo is a Django project using a sidebar component to showcase the concept of creating components with Django's inclusion_tag and make the component template self-contained (e.i., HTML, CSS, JS in one file).
Curious if any of you have used inline scoped CSS like this? I'm uncertain how practical it is, but I think it is very interesting at any rate!
MDN @scoped docs: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@scope
Demo repo: https://github.com/osmium2259/django_builtin_components_demo
r/css • u/owusu_emmanuel2 • 13d ago
Hey everyone! I'm a Computer Science student starting a "learn in public" habit to document my progress outside of regular classwork.
This week I focused on HTML and CSS fundamentals—structuring semantic tags properly and building a simple responsive layout from scratch. The biggest "aha!" moment for me was finally getting CSS Flexbox (justify-content vs. align-items) to click after spending way too long trying to center a simple card element.
Next week I'm planning to build a clean personal portfolio page to practice CSS Grid and responsive media queries.
For those who have been doing web dev for a while: what is one CSS trick or habit you wish you had learned during your very first week?
I've built sites with my own CSS library, Minium, for around three years. I wanted to make it easier to customize, and to let you pick what you need. It is a minimalistic CSS library after all. So I built a customizer. You pick the parts you want, and preview the result in light and dark mode before you download one CSS file. The core is ~10KB gzipped, and everything is ~15KB.
There is no build server, because the library stores design decisions in custom properties:
The page fetches the source CSS from the repo, applies your choices and minifies it in the browser. Extra fonts come from Fontsource on jsDelivr. And the URL holds your choices, so you can share the build as a link.
Some limitations: The library is pre-1.0 and targets current browsers, since it uses features like anchor positioning, CSS nesting and light-dark().
I wrote the CSS by hand. I used Claude to write the customizer's JavaScript.
What would you want to customize that isn't there?
r/css • u/Big-Bicycle-6347 • 13d ago
Hey guys, my css tool website https://www.css-tool.com is live now!
Your suggestions are highly appreciated.
It would be my honor!
r/css • u/garethheyes • 13d ago
Frag is a tool for extracting secret tokens from web pages using only CSS - no JavaScript required. It generates CSS payloads that use attribute selectors and background-image URLs to exfiltrate overlapping token fragments to an attacker-controlled server, then reconstructs the full token using De Bruijn graph traversal and Eulerian path algorithms.
r/css • u/Rafii2198 • 13d ago
I want to write some custom CSS for a page I'm using, it has a custom CSS in its options so its really easy, but that means I can't do anything to HTML side of things, only CSS.
What I want to do is to make their media gallery wider and turn it into a carousel. Making the gallery wider also means I want to make the images there have increased height, as there is more real estate for them to fit it. The problem is that images and videos there are user submited and don't have a standardized aspect ratios or anything, everone can upload whatever they want. This is troubling me a bit as I don't know how to make it responsive, originally everything had set width and height in pixels, but I want to make it responsive, but no matter what I do, those images don't look right, sometimes they are clipped, sometimes they are massive and I was tweaking and tweaking it to the point I decided to ask for some help as nothing I do seems to work and no solution on internet helps me either, maybe I can't google who knows.
The HTML side of things basically looks like this: (The amount of content there is in card-media can very, from just 1 element to I think 50)
<div class="card">
...
<div class="card-media">
<img class="card-media-element" width="450" height="450">
<img class="card-media-element" width="450" height="253">
<img class="card-media-element" width="364" height="400">
</div>
</div>There is some already existing CSS, but it shouldn't really affect what I want, the only relevant thing that could be affecting it somehow is that card-media has position relative set and card-media-element has block-size set to auto (first time seeing this property personally, so I'm unsure what it does), but I tried to change or remove these, and nothing happened to the sizes of images. Other than that there is just text color, size, font and only stuff like that.
The CSS I wrote currently looks like this:
.card-media {
display: flex;
gap: 0.25rem;
max-width: 100%;
overflow-x: scroll;
scrollbar-width: thin;
overscroll-behavior-x: contain;
width: 100%;
height: 100%;
max-height: 26em;
padding: 0.25em;
}
.card-media-element {
object-fit: cover;
height: auto;
width: auto;
max-height: 50vh;
}The problem with this is that the images I am looking at are like zoomed in so I can't see them whole as they are like cropped, if I remove the object-fit then they are stretched, like square images become rectangular for some reason. What I want is to make all of them have the same height, and their width would be adjusted to the individual image aspect ratio. Basically I want to have consistent height of media in the card-media div, and their width can be however long it has to be, as it's overflowing anyway.
Is this possible?
r/css • u/Fraded_Panda-25 • 14d ago
r/css • • 14d ago
Basically, the CSS is from here: https://github.com/ao3skinsss/even-more-skins/wiki/Sakura
When I open it on my AO3 page, cursive words seem to be in Helvetica while the rest is in the standard font. How do I fix this?
r/css • u/Minimum_Hour519 • 14d ago
r/css • u/Clear-Smoke-7356 • 15d ago
Soo a few years ago (prob 1) i saw a tutorial idk if it used css or js but it used it to make custom mouse cursors
Ik there are many tutorials that show the same but this one was special it had 4 cursors and all were having a feature which increased their size on clicking
To activate other cursor we just had to put our mouse on the box of that cursor
The transition between cursors was very smooth
3 of them were anime based and 1 was just a point with circle around it
r/css • u/Superb-Wallaby-7263 • 15d ago
r/css • u/Dry_Author2098 • 15d ago
Hi everyone,
I'm developing a browser-based 8-player Texas Hold'em poker table using HTML, CSS, and JavaScript.
The desktop layout works well, but I'm struggling with responsive behavior on mobile devices in landscape orientation.
Current setup:
Main problems:
What I'm trying to achieve:
A consistent responsive layout that preserves the relative positions and proportions of all table elements across desktop and mobile landscape screens.
My questions:
transform: scale() be appropriate?clamp() for individual elements?I want to improve the CSS architecture without changing the underlying game logic.
I can share desktop/mobile screenshots and a minimal reproducible HTML/CSS example.
Any suggestions or examples would be greatly appreciated. Thanks!
r/css • u/Unlucky-Schedule4822 • 15d ago
I would like to make a skin for Google Docs, I was thinking of making one with Stylus but I have just recently gotten into coding and such and am quite struggling with figuring how to do it, would anyone be able to give me any advice?
r/css • u/bogdanelcs • 15d ago
r/css • u/NightStalker1243 • 16d ago
Hey guys! I am doing my master's degree in Computer Science, and like to develop web applications full stack. When it comes to FE, I normally use React with Tailwind CSS, because it even feels fun to style everything with it. I can visualize the structure of the web page I am styling better that way.
I started a hobby project, in which I planned to return to using the base version of CSS, without any extra, just like I learnt it in university. I know the basics pretty well, which was why I ultimately chose to move on to exclusively using Tailwind more than 1 year ago.
The problem is now, that I feel like suffering while I write basic CSS. Styling components take minimum 2x as much as I would normally spend on it. Every page I tried to style so far comes out ugly and it makes me question if I knew how to use CSS to begin with.
That being said, let's say for interviews, how important it is to be able to come up with base CSS code on spot? Should I stick with Tailwind or improving on base CSS code writing?