CSS

When I use the `--sourcemap` argument in the CLI to generate the CSS builds with sourcemaps, when the CSS uses `@include`, it does not update the path and therefore will not work. In the code below, the builds are stored in the *dist* directory, while the CSS source code is stored in the *src* directory. This is my simple code to reproduce this... ``` - src/ - stylesheet.css - dist - my-package.css - my-package.css.map - demo.html - bundle.css - package.json ``` bundle.css ``` @import 'src/stylesheet.css'; ``` demo.html ``` <link rel="stylesheet" href="dist/my-package.css"> ``` package.json ``` { "name": "my-package", "version": "1.0.0", "license": "MIT", "scripts": { "build": "lightningcss --sourcemap bundle.css -o dist/my-package.css" }, "devDependencies": { "lightningcss-cli": "^1.25.1" } } ``` src/stylesheet.css ``` body { background-color: red; } ``` dist/my-package.css output ``` @import "src/stylesheet.css"; /*# sourceMappingURL=dist/my-package.css.map */ ``` What I expected from the dist/my-package.css output ``` @import "../src/stylesheet.css"; /*# sourceMappingURL=dist/my-package.css.map */ ``` Does anyone know why this is the outcome? Any help will be most appreciated.

2
0

I created a banner image for a webpage and by specifying a width of 100% and a max-width of 1024px I got an image that scales down on small devices but also doesn't get to big on large displays. Perfect. I decided that I'd like it to be a slideshow so I've been testing this pure CSS implementation https://codepen.io/gradar/pen/BaavLLo The problem is that on smaller devices, the images are too big. So I tried applying the same CSS I did for my static image but it didn't work. I assume that this is due to the CSS animation specifying funky margins. Is it possible to get the same behaviour that my banner does on the codepen example? PS: My page with the working banner image is here in case it makes it clearer https://optimumhealth.ie/yoga-festival/

6
10

cross-posted from: https://lemmy.world/post/2692134 > SOLVED: by @g6d3np81@kbin.social [using `columns` property](https://mlmym.org/lemm.ee/comment/2050770) > > TL;DR: I want to achieve [this behavior for the menu layout](https://crul.github.io/CursoRelatividadGeneralJavierGarcia/), but [all I can get is this](https://i.imgur.com/me2RPva.png); note the different menu options order. > > Two days ago [I asked for help](https://old.lemmy.world/post/2566953) for implementing the current behavior without hardcoding the menu height for each resolution step, and there were two suggestions to try `display: grid`. It looked promising and after reading some documentation I was able to get [something very close to what I'm looking for](https://i.imgur.com/me2RPva.png). > > The only difference being that I want the chapters to be sorted vertically (as [in the current version](https://crul.github.io/CursoRelatividadGeneralJavierGarcia/)), but what I got sorts the chapters horizontally. > > Here it is (what I think is) the relevant code: > > #menu ul { > display: grid; > grid-template-columns: 1fr 1fr 1fr 1fr; > grid-auto-flow: row dense; > } > > Sorry, I don't have the `display: grid` version online. > > I did a quick search for [display grid multiple columns vertical sort](https://www.google.com/search?q=display+grid+multiple+columns+vertical+sort&amp;newwindow=1&amp;hl=en) and saw this [StackOverflow post: CSS Grid vertical columns with infinite rows](https://stackoverflow.com/questions/44906501/css-grid-vertical-columns-with-infinite-rows) which, if I understand correctly, says it's not possible. But I'm pretty sure I'm not understanding it correctly. > > Any help will be welcome, thanks! > > EDIT: I also tried `grid-audto-flow: column` (as [suggested here](https://lemmy.world/comment/2095002)) but [it just renders a single row](https://i.imgur.com/ARhEad0.png). Probably because I'm missing something... > > #menu ul { > display: grid; > grid-template-columns: 1fr 1fr 1fr 1fr; > grid-auto-flow: column; > } > > EDIT-2: I was told that for `grid-audto-flow: column` to work I need to specify the numbers of columns. If I understand correctly, then that doesn't really help. The original issue is that I need to edit the CSS file every time a new chapter is added. Which would be the same if I have to hardcode the number of rows. > > I mean, it's a bit cleaner to hardcode the number of rows than the height in pixels, but I was looking for a solution that doesn't require magic numbers in the CSS.

4
0

cross-posted from: https://lemmy.world/post/2566953 > Hi, I'm an old webdev who is rusty in CSS; I learn about `calc()` recently and never really learnt `display: flex` properly. > > I made [some webs with a responsive menu layout](https://crul.github.io/CursoTeoriaCuanticaDeCamposJavierGarcia/) (relevant CSS code posted on bottom). I tried using flex but I still had to do one ugly hack: I have the menu heights for the different resolutions hardcoded and I have to update them manually every time a new chapter is added. It's not a big deal, but I would like to know if there is a proper way to do this. > > Some alternatives I've thought about: > - [The new `round()`](https://developer.mozilla.org/en-US/docs/Web/CSS/round), but it's too new and not supported by most browsers. > - JavaScript > > ... but I feel like there must be a clean CSS-only way to achieve this. > > Thanks! > > Relevant CSS code ([link to full stylesheet](https://crul.github.io/CursoTeoriaCuanticaDeCamposJavierGarcia/style.css?v=20220826) in case I missed something). > > ul { > display: flex; > flex-direction: column; > flex-wrap: wrap; > height: 624px; /* =27x23+3 | 23 = 91/4 */ > margin: 0; > padding: 16px 16px 4px 16px; > vertical-align: top; > } > @media screen and (max-width: 1000px) { > ul { > height: 840px; /* =27x31+3 | 31 = 91/3 */ > } > } > @media screen and (max-width: 582px) { > ul { > height: 1245px; /* =27x46+3 | 46 = 91/2 */ > } > } > @media screen and (max-width: 400px) { > ul { > height: auto; > } > } > ul li { > list-style-type: none; > margin: 2px 16px 2px 4px; > font-size: 120%; > } > ul li a { > display: inline-block; > background-color: #3fa79e; > color: #d2e7e2; > text-decoration: none; > padding: 2px 8px; > border: solid 1px #d2e7e2; > } > ul li a:first-child { > width: 106px; > margin-right: -3px; > } > ul li a:hover { > background-color: #144c48; > color: #fff; > border: solid 1px #fff; > } >

3
1

I asked for help making the expanded images fully expand [here](https://lemmy.world/post/1447011). They got something workable, but it gets rid of the sidebar. I'm hoping for something where the image just covers the sidebar. I found the class, but I don't know how to write the CSS to make it go all the way across the screen regardless of the parent. So it would start with `.img-expanded:not(.banner):not(.avatar-overlay) { }` but I need to know what goes in the brackets.

1
0
https://i.imgur.com/7VfL6Js.png

This [basic responsive collapse](https://codepen.io/zmodem-/pen/eYGWxPK) CodePen example shows a very limited range of how borders and elements are told to collapse based on a certain set of rules. This is a great jumping off point for anyone interested in how responsive media queries work.

1
0
https://i.imgur.com/N2pB9eK.png

Check out this [primitive product container](https://codepen.io/zmodem-/pen/dymoYbe) which showcases a brief layout for displaying products on a page in a [Flex container](https://www.w3schools.com/css/css3_flexbox_container.asp).

1
0
https://i.imgur.com/zz6ehNX.png

Hey everyone! Check out [this not-so-basic example](https://codepen.io/zmodem-/pen/GRdjRZX) of how to create an alternative method of an [image navigation](https://www.tutorialspoint.com/How-to-use-an-image-as-a-link-in-HTML) container.

1
0
https://i.imgur.com/5ns0Xcl.png

See [this CodePen example](https://codepen.io/zmodem-/pen/yLjLzEj) which showcases how we can utilize some basic [CSS Grid](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout) rules in order to setup a basic, [responsive layout](https://www.w3schools.com/html/html_responsive.asp). This example has *a ton* of room for improvement, and even some bad practices. However, the basic premise of a good "jumping off point" still holds true.

1
0
https://i.imgur.com/D0Oq2vo.png

[Check out this CodePen](https://codepen.io/zmodem-/pen/NWMpRwQ) in order to see just how inner and outer padding and aesthetic modification affects parents, children, and siblings. Moreover, let's see how the way the entire element's placement on the page is changed depending on our rules for the inner and outer containers.

1
0
https://i.imgur.com/z6d6uLH.png

Welcome! So, as we iron out all of the details regarding what this sub will be "for," let's just get this first post out of the way so that everyone understands that this is not just for squatting. This space will eventually be a CSS help community within Lemmy. More to come! Stay tuned. PS: Looking for moderators. If your intentions are to swindle a moderation appointment from the existing mods, please do us all a favor and don't embarrass yourself by trying.

1
0