CSS Attribute Selector doesn't work - css

I try to select the red-colored paragraph and apply border to it. Why this piece of code is not working?
p[color="red"] {
border: 1px solid black;
}
<p style="color: green;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p style="color: yellow;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p style="color: lime;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p style="color: darkgray;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p style="color: red;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p style="color: cyan;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p style="color: indigo;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
Am I missing something?
fiddle: https://jsfiddle.net/kLx1gcq0/

[] is a attribute selector, so you would have to select the style attribute like:
p[style*="color: red"] {
border: 1px solid black;
}
JSFiddle Demo
*= selects the element if the attribute contains the string specified. An excellent article about CSS selectors can be found here.
That works, but only if there is a whitespace. If you don't know if it will have a whitespace or not, you could do it like:
p[style*="color: red"],
p[style*="color:red"] {
border: 1px solid black;
}

It doesn't work since color is not an HTML attribute, which is what [color=...] matches against.
In general, inline styling is deprecated. You should use CSS for styling and the common practice is to use classes.
Try this instead:
p.red {
color: red;
border: 1px solid black;
}
p.green {
color: green;
}
p.yellow {
color: yellow;
}
p.lime {
color: lime;
}
<p class="green">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p class="yellow">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p class="lime">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>
<p class="red">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, provident, nam, et, consectetur molestiae aspernatur ratione placeat dignissimos odio cum non eveniet adipisci voluptas doloribus fugiat maiores odit sint repellat.</p>

The selector p[color="red"] isn't working because the element doesn't have a color attribute. Since you're trying to match based on the style attribute, your selector could be:
Example Here
p[style="color: red;"] {
border: 1px solid black;
}
However, it's worth mentioning that this will match the attribute's value exactly, so it likely won't work all the time. You could match based on whether the value contains color: red:
p[style*="color: red"] {
border: 1px solid black;
}
However, that may not work if whitespace varies or if the value is background-color: red. Of course you could select all the different variants, but if you can, I would highly suggest avoid using the attribute selector like this. Classes are better suited for this sort of thing.

The attribute selectors are designed to identify HTML attributes, not CSS properties. The following may work however (untested):
p[style*="color: red;"] {
border: 1px solid black;
}
<p style="color: green;">Green text</p>
<p style="color: yellow;">Yellow text</p>
<p style="color: lime;">Lime text</p>
<p style="color: darkgray;">Dark gray text</p>
<p style="color: red;">Red text</p>
<p style="color: cyan;">Cyan text</p>
<p style="color: indigo;">Indigo text</p>

The selector is wrong. p[color="red"] means "a P element that have an attribute "color" with a value of "red"... but you have "style" attribute, not "color".
Take a look to css selectors: http://www.w3.org/TR/css3-selectors/#selectors

Yeah, so simple mistake. Obviously, color is not an html attribute.
Working solutions:
p[style*="color"][style*="red"] {
border: 1px solid black;
}
p[style*="color: red"],
p[style*="color:red"] {
border: 1px solid black;
}
Special, thanks to Jacob Gray

Related

Why does CSS "blur" backdrop-filter not work in Chrome?

In CSS, I use the backdrop-filter property to blur the background of the sticky header.
Therefore, I used backdrop-filer:blur(10px) and set opacity:50%.
If you run the code, the sticky header background will not blur. Can you tell me why the sample code doesn't work?
.sticky{
background-color:orangered;
opacity: 50%;
backdrop-filter: blur(10px);
position: sticky;
top:0;
height: 100px;
}
<body>
<div class="sticky">
<h1>This is a header</h1>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam
asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque
nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat
tempora.
</p>
<div style="height: 400px"></div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam
asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque
nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat
tempora.
</p>
<div style="height: 400px"></div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam
asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque
nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat
tempora.
</p>
<div style="height: 400px"></div>
</body>
Chrome does support backdrop-filter. https://caniuse.com/?search=backdrop-filter.
backdrop-filter does not work in conjunction with background-color.
You cannot see a blur effect if there is no background to blur. A blurred solid colour would look exactly the same!
I recommend also removing opacity.
If you want to change the background color, try using:
backdrop-filter: sepia(.8);
backdrop-filter: hue-rotate(30deg);
to get the desired efffect.
body {
background: url(https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages8.alphacoders.com%2F992%2F992848.jpg);
background-size: contain;
}
#supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
.sticky {
backdrop-filter: blur(10px);
position: sticky;
top: 0;
height: 100px;
}
}
<body>
<div class="sticky">
<h1>This is a header</h1>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat tempora.
</p>
<div style="height: 400px"></div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat tempora.
</p>
<div style="height: 400px"></div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat tempora.
</p>
<div style="height: 400px"></div>
</body>
Try directly state opacity using RGBA in the background-color, it will work:
.sticky{
background-color:rgba(255,69,0,0.5); //orangered = rgb(255,69,0)
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px); //mobile-friendly
position: sticky;
top:0;
height: 100px;
}
<body>
<div class="sticky">
<h1>This is a header</h1>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam
asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque
nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat
tempora.
</p>
<div style="height: 400px"></div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam
asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque
nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat
tempora.
</p>
<div style="height: 400px"></div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam
asperiores at autem, dicta dignissimos ex, fugiat fugit harum id itaque
nulla odio perferendis quasi qui similique! Doloribus nesciunt quaerat
tempora.
</p>
<div style="height: 400px"></div>
</body>
background-filter does not work in conjunction with background-color.
.sticky{
background-color:#3ea66263;
backdrop-filter: blur(10px);
position: sticky;
top:0;
height: 100px;
}
Works well for me. Did I miss something ?

Article layout with CSS Grid: how to wrap text around images (or float them)?

I know that direct children of a grid item cannot be floated. I'm trying to create an article layout where something like this is achieved: pull an image to either side, and have the text flow around it.
Here's what I have so far on Codepen. With named template columns, I can have an image fill up only part of the width of the grid, but is there any way to let the surrounding text flow around it?
Hopefully my Codepen example makes sense; please let me know if I can provide additional information or clarification!
figure {
margin: 0;
}
img {
max-width: 100%;
height: auto;
}
article {
max-width: 800px;
margin: auto;
display: grid;
grid-template-columns: [wide-start] minmax(1em, 1fr) [main-start] minmax(0, 16em) [main-half] minmax(0, 16em) [main-end] minmax(1em, 1fr) [wide-end];
}
article>* {
grid-column: main;
}
figure {
grid-column: wide-start / main-half;
}
div {
grid-column: main-half / main-end;
padding-left: 1em;
}
<article>
<h1>Article</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore dolorem porro vero! In iste nemo repellendus? Doloremque eius officia beatae doloribus autem vitae enim qui. Minus, facere? Quaerat, laboriosam enim?</p>
<figure>
<img src="https://via.placeholder.com/500x300">
<figcaption>
<p>I wish the text could wrap around to my right</p>
</figcaption>
</figure>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Sunt, obcaecati, blanditiis ad nostrum autem atque error quasi, tempora debitis exercitationem illum. Maiores cum delectus, fugit repellat provident libero hic magni?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates consectetur aspernatur est numquam alias consequatur praesentium quaerat totam dicta non asperiores similique inventore, a perspiciatis perferendis laudantium minus ratione animi!</p>
<figure>
<img src="https://via.placeholder.com/500x300">
<figcaption>
<p>Text is now in a column next to me (because I wrapped it in a <code><div></code>, but it won't wrap underneath me automatically</p>
</figcaption>
</figure>
<div>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Fugiat repellat consequatur, voluptas sint eum ea error sit hic dignissimos expedita totam suscipit officia consequuntur non, quaerat odio. Recusandae, consequatur maxime!</p>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Itaque eveniet, pariatur ipsa fuga hic nihil unde maiores, provident eius minima atque accusamus voluptate aspernatur perferendis. Ab rem inventore omnis at!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. At vitae ex fugit sequi, natus asperiores? Laudantium optio, doloribus error dolores exercitationem aliquid esse, reiciendis mollitia alias vel illo, amet officiis?</p>
</div>
</article>
If I understood you correctly and you don't have to use only CSS Gird for the whole layout you can wrap your figure and paragraphs in another div, then trough that div give your figure max width of 50%, float:left, and some margin-right... you get the point.
figure { margin: 0; }
img { max-width: 100%; height: auto; }
article {
max-width: 800px;
margin: auto;
display: grid;
grid-template-columns:
[wide-start] minmax(1em, 1fr)
[main-start] minmax(0, 16em)
[main-half] minmax(0, 16em) [main-end]
minmax(1em, 1fr) [wide-end];
}
article > * {
grid-column: main;
}
.floating{
margin-bottom: 20px;
border-bottom: 1px solid #ddd;
}
.floating figure {
float:left;
max-width: 50%;
margin-right: 20px;
}
.floating p {
margin-top:0;
}
<article>
<h1>Article</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore dolorem porro vero! In iste nemo repellendus? Doloremque eius officia beatae doloribus autem vitae enim qui. Minus, facere? Quaerat, laboriosam enim?</p>
<div class="floating">
<figure>
<img src="https://via.placeholder.com/500x300">
<figcaption>
<p>I wish the text could wrap around to my right</p>
</figcaption>
</figure>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Sunt, obcaecati, blanditiis ad nostrum autem atque error quasi, tempora debitis exercitationem illum. Maiores cum delectus, fugit repellat provident libero hic magni?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates consectetur aspernatur est numquam alias consequatur praesentium quaerat totam dicta non asperiores similique inventore, a perspiciatis perferendis laudantium minus ratione animi!</p>
</div>
<div class="floating">
<figure>
<img src="https://via.placeholder.com/500x300">
<figcaption>
<p>Text is now in a column next to me (because I wrapped it in a <code><div></code>, but it won't wrap underneath me automatically</p>
</figcaption>
</figure>
<div>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Fugiat repellat consequatur, voluptas sint eum ea error sit hic dignissimos expedita totam suscipit officia consequuntur non, quaerat odio. Recusandae, consequatur maxime!</p>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Itaque eveniet, pariatur ipsa fuga hic nihil unde maiores, provident eius minima atque accusamus voluptate aspernatur perferendis. Ab rem inventore omnis at!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. At vitae ex fugit sequi, natus asperiores? Laudantium optio, doloribus error dolores exercitationem aliquid esse, reiciendis mollitia alias vel illo, amet officiis?</p>
</div>
</div>
</article>

Fixed div on the bottom of the scrollable div

I need a create 4 cards with non-changable height with buttons on the bottom, but there are different text amount in each card.
Position Fixed is connected to body element,
position absolute scrolls with content,
position sticky appears when content ends.
https://codepen.io/anatoli101/pen/NVzbGY Here is a basic exemple of my problem
.content{
display:flex;
width: 100%;
justify-content: space-around;
}
.fixed-div{
background-color: red;
height: 400px;
width: 300px;
overflow-y: auto;
}
.button{
position:sticky;
bottom:0;
background-color: grey;
width: 100%;
height: 30px;
}
You'll get a much nicer result (no occluded scrollbars) using flex:
.content {
display: flex;
justify-content: space-evenly;
height: 400px;
}
.container {
display: flex;
flex-direction: column;
flex: 0 1 250px;
margin: 0 5px;
}
.fixed-div {
background-color: red;
overflow-y: auto;
flex: 1 1 auto;
}
.button {
background-color: grey;
flex: 0 0 30px;
}
<h1>I need grey area fixed on the bottom, not dependent on text amount</h1>
<div class="content">
<div class="container">
<div class="fixed-div">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad dolores aspernatur error rem aliquam omnis eveniet consequuntur asperiores, aut explicabo eaque eos quos facere necessitatibus sit est ipsam quae optio! Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque molestias natus officiis labore omnis corporis cupiditate quisquam nihil? Mollitia aperiam iusto iste minima ratione culpa veniam architecto facilis neque deleniti? Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cumque aut, eum, quia facere inventore perferendis aperiam recusandae nihil at aliquam ipsum excepturi eligendi animi, nam vel unde. Suscipit, tenetur veritatis. Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eaque, quam. Hic unde nam dolor debitis voluptates officia earum, nostrum ut quae recusandae voluptate eveniet commodi ipsa dolorum nulla totam molestiae?</p>
</div>
<div class="button"></div>
</div>
<div class="container">
<div class="fixed-div">
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cumque aut, eum, quia facere inventore perferendis aperiam recusandae nihil at aliquam ipsum excepturi eligendi animi, nam vel unde. Suscipit, tenetur veritatis. Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eaque, quam. Hic unde nam dolor debitis voluptates officia earum, nostrum ut quae recusandae voluptate eveniet commodi ipsa dolorum nulla totam molestiae?</p>
</div>
<div class="button"></div>
</div>
<div class="container">
<div class="fixed-div">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad dolores aspernatur error rem aliquam omnis eveniet consequuntur asperiores, aut explicabo eaque eos quos facere necessitatibus sit est </p>
</div>
<div class="button"></div>
</div>
<div class="container">
<div class="fixed-div">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad dolores aspernatur error rem aliquam omnis eveniet consequuntur asperiores, aut explicabo eaque eos quos facere necessitatibus sit est ipsam quae optio! Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque molestias natus officiis labore omnis corporis cupiditate quisquam nihil? Mollitia aperiam iusto iste minima ratione culpa veniam architecto facilis neque deleniti? Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cumque aut, eum, quia facere inventore perferendis aperiam recusandae nihil at aliquam ipsum excepturi eligendi animi, nam vel unde. Suscipit, tenetur veritatis. Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eaque, quam. Hic unde nam dolor debitis voluptates officia earum, nostrum ut quae recusandae voluptate eveniet commodi ipsa dolorum nulla totam molestiae?</p>
</div>
<div class="button"></div>
</div>
</div>
A good way to achieve this is by wrapping the element with the class fixed-div inside a container, and moving the element with the class button outside of the element with the class fixed-div, so that it is the direct child of the container element. Then you can set position: relative to the container element, and position: absolute to the element with the class button. As the container element will have the exact same size (and especially the same height) as the element with the class fixed-div, the element with the class button will be positioned at its bottom.
You also will need to add a bottom padding to the element with the class fixed-div so that the button doesn't not hide its content, and so that it doesn't affect its defined height, you can set its box-sizing property to border-box.
See the following code:
.content {
display: flex;
width: 100%;
justify-content: space-around;
}
.container {
position: relative;
}
.fixed-div {
box-sizing: border-box;
width: 150px;
height: 400px;
padding-bottom: 30px;
overflow-y: auto;
background-color: red;
}
.button {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
background-color: grey;
}
<h1>I need grey area fixed on the bottom, non depending of text amount </h1>
<div class="content">
<div class="container">
<div class="fixed-div">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad dolores aspernatur error rem aliquam omnis eveniet consequuntur asperiores, aut explicabo eaque eos quos facere necessitatibus sit est ipsam quae optio!loremLorem ipsum dolor sit amet consectetur adipisicing elit. Itaque molestias natus officiis labore omnis corporis cupiditate quisquam nihil? Mollitia aperiam iusto iste minima ratione culpa veniam architecto facilis neque deleniti?Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cumque aut, eum, quia facere inventore perferendis aperiam recusandae nihil at aliquam ipsum excepturi eligendi animi, nam vel unde. Suscipit, tenetur veritatis.Lore Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eaque, quam. Hic unde nam dolor debitis voluptates officia earum, nostrum ut quae recusandae voluptate eveniet commodi ipsa dolorum nulla totam molestiae?</p>
</div>
<div class="button"></div>
</div>
<div class="container">
<div class="fixed-div">
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cumque aut, eum.</p>
</div>
<div class="button"></div>
</div>
<div class="container">
<div class="fixed-div">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad dolores aspernatur error rem aliquam omnis eveniet consequuntur asperiores, aut explicabo eaque eos quos facere necessitatibus sit est ipsam quae optio!loremLorem ipsum dolor sit amet consectetur adipisicing elit. Itaque molestias natus officiis labore omnis corporis cupiditate quisquam nihil? Mollitia aperiam iusto iste minima ratione culpa veniam architecto facilis neque deleniti?Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cumque aut, eum, quia facere inventore perferendis aperiam recusandae nihil at aliquam ipsum excepturi eligendi animi, nam vel unde. Suscipit, tenetur veritatis.Lore Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eaque, quam. Hic unde nam dolor debitis voluptates officia earum, nostrum ut quae recusandae voluptate eveniet commodi ipsa dolorum nulla totam molestiae?</p>
</div>
<div class="button"></div>
</div>
<div class="container">
<div class="fixed-div">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad dolores aspernatur error rem aliquam omnis eveniet consequuntur asperiores, aut explicabo eaque eos quos facere necessitatibus sit est ipsam quae optio!loremLorem ipsum dolor sit amet consectetur adipisicing elit. Itaque molestias natus officiis labore omnis corporis cupiditate quisquam nihil? Mollitia aperiam iusto iste minima ratione culpa veniam architecto facilis neque deleniti?Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cumque aut, eum, quia facere inventore perferendis aperiam recusandae nihil at aliquam ipsum excepturi eligendi animi, nam vel unde. Suscipit, tenetur veritatis.Lore Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eaque, quam. Hic unde nam dolor debitis voluptates officia earum, nostrum ut quae recusandae voluptate eveniet commodi ipsa dolorum nulla totam molestiae? </p>
</div>
<div class="button"></div>
</div>
</div>
I reduced the width of the text elements so that it works within a narrow container, you can run the code in full page if it is still too narrow.
Leaving the button inside the scrolling element and setting position: relative to the latter and position: absolute to the former wouldn't work as the bottom of the button would be positioned inside the scrolling element at 400px which is the height of the scrolling element, and would scroll with its content.
Hope that helps.
You can try code:
.fixed-div p{
display: block;
margin: 0;
padding: 10px;
height: 350px;
}
This is a demo: https://codepen.io/phuongnm153/pen/zQaobq
use position: relative; for the parent (fixed-div) and position:absolute;bottom:0; for the child (button)
.content{
display:flex;
width: 100%;
justify-content: space-around;
}
.fixed-div{
position: relative;
background-color: green;
height: 400px;
width: 300px;
overflow-y: auto;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.button{
position:relative;
background-color: grey;
width: 100%;
height: 30px;
display: inline-table;
}

Is there a way to target all classes in css?

Is is possible to write css rules to select and style all elements with non-empty class attributes?
Lets say I have 2 different paragraphs or headers with different classes. For example, h1 has a class of "id1" and h2 has a class of "id2".
How can I style them both?
Thank you.
you may use:
.id1, .id2{
//your css here
}
Or if you mean all elements which have a class attribute, then you may use:
*[class]{
//your css
}
But the above, also selects elements with an empty class such as:
<h1 class></h1>
or
<h1 class=""></h1>
to exclude such exceptions, you can modify the selector to:
*[class]:not([class=""])
You can use attribute selector like this:
[class] {
color: red;
}
<p class="a">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod quam praesentium alias recusandae tempora perspiciatis molestias accusamus ad in fuga, officiis id voluptate, quasi, rem inventore, illum sint voluptatem. Dolor.</p>
<p class="b">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod quam praesentium alias recusandae tempora perspiciatis molestias accusamus ad in fuga, officiis id voluptate, quasi, rem inventore, illum sint voluptatem. Dolor.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod quam praesentium alias recusandae tempora perspiciatis molestias accusamus ad in fuga, officiis id voluptate, quasi, rem inventore, illum sint voluptatem. Dolor.</p>
h1[class] {
color: blue;
}
<h1 class="a">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod quam praesentium alias recusandae tempora perspiciatis molestias accusamus ad in fuga, officiis id voluptate, quasi, rem inventore, illum sint voluptatem. Dolor.</p>
<h1 class="b">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod quam praesentium alias recusandae tempora perspiciatis molestias accusamus ad in fuga, officiis id voluptate, quasi, rem inventore, illum sint voluptatem. Dolor.</p>
<h2 class="c">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod quam praesentium alias recusandae tempora perspiciatis molestias accusamus ad in fuga, officiis id voluptate, quasi, rem inventore, illum sint voluptatem. Dolor.</p>

CSS white inner shadow

How can I make white inner shadow in the div?
I've trying with other colors — works fine, but with white color that don't work.
JSBin example
Thanks!
Update:
I need something like this:
Alternatively, you can create a simple overlay on the layer above the content and make it your box-shadow
.container {
height: 300px;
width: 300px;
background: #fff;
border: 1px solid #cecece;
border-radius: 4px;
position: relative;
}
.container .content {
overflow: auto;
height: 100%;
}
.container:after {
width: calc(100% - 20px);
height: 110px;
background: linear-gradient(180deg, #fff, transparent);
position: absolute;
top: 0;
left: 0;
content: close-quote;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div class="container">
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro nesciunt quo fuga quasi vero modi aspernatur
nemo harum sapiente nobis ex aliquam excepturi possimus sit laboriosam libero adipisci non aliquid.Lorem
ipsum dolor sit amet, consectetur adipisicing elit. Dicta libero modi debitis ipsa architecto nihil
exercitationem cumque natus ducimus at quae doloribus illum optio aut expedita eveniet magnam officiis
qui!Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam officia reiciendis doloremque neque
debitis aperiam voluptates non libero atque ut iure rem consequuntur alias commodi velit asperiores sit
nesciunt minima. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos dolor ab animi ullam id
incidunt tempore atque doloremque quidem quaerat soluta eaque expedita aspernatur velit reprehenderit
doloribus similique. Quod non.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit delectus iste
aliquid vero ut? Odio quas asperiores odit velit vitae aspernatur beatae! Adipisci molestias placeat maiores
eos voluptatum assumenda sunt.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci similique
quos fugit nostrum neque sit repudiandae error laborum possimus voluptatum molestiae impedit quo repellendus
minus corrupti doloribus itaque ipsa consequatur!Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Consequuntur molestias odit numquam soluta veniam saepe incidunt dolore praesentium nobis labore amet cumque
aliquam et consectetur est at quis voluptas doloremque?
</div>
</div>
</body>
</html>
box-shadow: grey 0px 30px 40px -2em inset;
Use grey into white.
If I understood well, you want a white shadow inside a white input? You need a different color to make the shadow.
I have maybe misunderstood, don't know. Tell me if this helped or if I just didn't understand.

Resources