CSS add more properties to class [duplicate] - css

This question already has answers here:
Can a CSS class inherit one or more other classes?
(29 answers)
Closed 9 years ago.
This might be a noob question, but I'm trying to search by terms like "CSS add more propertiers to existent class"; "Add CSS properties to class"; etc and I can't find what I'm looking for.
Imagine I have this:
.ui-bar { color: red }
Now I want to extend this property, but continue with the same color red.
.ui-bar-margin { margin-top: 10px; }
How can I accomplish this? If you want, you can point me links or terms to search for.
Thanks!

You just do it like this... Here's a lot of examples.
.ui-bar {
color: red;
margin-top: 10px;
background: white;
width: 300px;
display: block;
text-align: left;
}

Related

CSS: How to make a shape that reach the page borders? [duplicate]

This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Closed 1 year ago.
I started studying CSS and I'm using an online IDE called replit to do some tests.
Today I've tried to create a simple rectangle shape and I realized that it couldn't reach the page borders, so I'm here to ask how to make this rectangle to reach it (https://2.thiagoalonso05.repl.co).
I created an empty div and put its class as greybar, after that, I went to CSS. Here's my code:
body {
background-color: #181818;
}
.greybar {
display: block;
height: 48px;
background-color: #202020;
}
Here's an image showing where I want the grey bar to reach (the red part):
Just remove the default margin and padding.
* {
margin:0;
padding:0;
}
body {
background-color: #181818;
}
.greybar {
display: block;
height: 48px;
background-color: #202020;
}
<div class="greybar"></div>

How to change first three letters of a word [duplicate]

This question already has answers here:
Change CSS After x Characters
(3 answers)
Closed 3 years ago.
I wanted to create a wordpress website and in its live CSS edit part I selected the website name "Standard" and then I tried to change the first letters using :nth-child and :nth-letter pseudo classes. But I can't. Can I edit the site name with CSS styles. The way I chose to select the word was using these classes: header .logo .site-title and I put the pseudo-classes like this:
header .logo .site-title:nth-child(1):nth-letter(-n+2) {
color: pink;
}
And so the way I tried has'nt worked. Can you help me to solve the problem and people who are searching about this?
.site-title {
color: pink;
}
Try to use this CSS
.site-title:after {
color: black;
color: blue;
content: attr(data-descr);
left: 0;
position: absolute;
}
And HTML
<div class="site-title" data-descr="S T">SITE TITLE</div>

Css assign multiple style blocks for one class [duplicate]

This question already has answers here:
Can a CSS class inherit one or more other classes?
(29 answers)
Closed 6 years ago.
Can I wrap a class (or id) around styling to apply it to elements only in that class?
For example, I have :
.title {
color: #000;
}
.block {
width: 100%;
}
.wrapper {
width: 90%;
}
I'd like to create a different design for these things, if they are in a specific class. I know You can do it like so:
.specific_class .title{
color: #fff;
}
But then I have to add it to each block. Can I do something like this?
.specific_class{
.title {
color: #fff;
}
.block {
width: 99%;
}
.wrapper {
width: 91%;
}
}
..just to assign different styles to work, if elements are in a specific class.
(I know the last example doesn't actually work).
I have a lot of these little blocks, so one "wrapping" would work and look a lot better than copy/pasting .specific_class in front of each one.
I'd like to apologize, if such question exists. I just couldn't find the correct words and find the solution, but there probably is a question like mine.
It is not possible in regular CSS. However, you might be interested in SASS, a CSS preprocessor that allows you to write nested rules (amongst other things) and compile them down to regular CSS.

Background with different colored rows - css only [duplicate]

This question already has answers here:
Alternate table row color using CSS?
(11 answers)
Closed 6 years ago.
is it possible to create a background with rows which are different colored?
Here's some Pseudo-Code to illustrate it:
body {
row-1 {
height: 250px;
background-color: red;
}
row-2 {
height: 250px;
background-color: yellow;
}
.
.
.
row-n {
height: 250px;
background-color: green;
}
}
Is it possible to do that in css only?
You can use gradient to achieve this. You can use a online css gradient generator. Here is an example.
EDIT: I think I misinterpreted your question. Are you just asking how to give different divs in your body different colors? either give them all distinctive classes so you can style each of them independently, or use :nth-child(x) where you replace x with the div number you want to style (e.g. if you want to style the second div, use :nth-child(2)

Operations on base values with Less CSS [duplicate]

This question already has answers here:
Lighten parent's (unknown) background-color in child
(3 answers)
How to override a LESS mixin variable based on a parent's variable
(1 answer)
Closed 7 years ago.
Hi I'm new to using Less and trying to make the best of the features it offers. What I would like to do is the following:
say I have a few anchor elements in html
Blue link
Red link
Green link
and I have the following css
.gen-link-prop {
text-decoration: none;
padding: 10px 40px;
color: #fff;
display: inline-block;
margin: 0 5px;
}
#blue-link-color: #9999ff;
#red-link-color: #ff9999;
#green-link-color: #99ff99;
.blue-link {
.gen-link-prop;
background-color: #blue-link-color;
}
.red-link {
.gen-link-prop;
background-color: #red-link-color;
}
.green-link {
.gen-link-prop;
background-color: #green-link-color;
}
.blue-link:hover, .red-link:hover, .green-link:hover {
background-color: darken(#<-- reference to base color here--<, 20%);
}
I want to be able to apply an operation to a property value that is already applied to the element. Is this even possible? Or is it something simple that I missed somewhere. Help is greatly appreciated

Resources