color opacity is not matching even tho value is same.

in figma and css the values are same but in browser it is showing totally different for better understanding i have attached half cut image of pc and first image that shows micro is figma design. blue : rgba(48, 122, 193, 0.2) green : rgba(181, 191, 161, 0.2)
No description
No description
No description
57 Replies
peterpumkineaterr
when i apply those colors to .wb which is before state of cards they get the color right but when i apply it .wb:hover then it shows lighter color
ἔρως
ἔρως4w ago
you do know it is absolutely impossible to know what's going on without actually seeing the site, right? but, i bet you have a filter: brightness(0.7) somewhere
peterpumkineaterr
no i don't think so let me setup the codepen for this
ἔρως
ἔρως4w ago
it's actually impossible to be certain without seeing
peterpumkineaterr
here's the codepen for this
Chris Bolson
Chris Bolson4w ago
As far as I can tell you are seeing this difference because you have given the elements a pseudo element with a background color of semi-transparent white rgba(255, 255, 255, 0.2); This initally has an opacity of 0 but transitions to 1 on hover. This pseudo element is covering your main background colors (which are also have a transition from "none" to the defined color on hover) which is giving them this toned down effect that you are seeing.
peterpumkineaterr
any solution on that ?
ἔρως
ἔρως4w ago
remove .wb::before?
Chris Bolson
Chris Bolson4w ago
don't add the psuedo element - why do you need it?
ἔρως
ἔρως4w ago
from what i read in the code, all it does is to be on top of everything and since it has 0.2 opacity on the white background, it will make things whiter/washed out just simply remove it
ἔρως
ἔρως4w ago
No description
No description
Chris Bolson
Chris Bolson4w ago
as a side note, not relevant to the issue, "//" is not a valid way to comment out code in CSS
ἔρως
ἔρως4w ago
left image: pseudo-element is there right image: pseudo-element is disabled this is supposed to be sass code
Chris Bolson
Chris Bolson4w ago
OK 👍
ἔρως
ἔρως4w ago
but you are right in css, it is invalid but is valid sass this was copy-paste from sass
peterpumkineaterr
i did not know can you tell me how can i do it proper way
ἔρως
ἔρως4w ago
css itself only supports /* ... */
Chris Bolson
Chris Bolson4w ago
and that can be on single or multiple lines to cover a code block
/*
.p{
color: red;
font-size: 1rem;
}
*/
.card{
/*border: 1px solid blue;*/
padding: 2em;
}
/*
.p{
color: red;
font-size: 1rem;
}
*/
.card{
/*border: 1px solid blue;*/
padding: 2em;
}
peterpumkineaterr
oh i see
ἔρως
ἔρως4w ago
but what you have is absolutely perfectly fine in sass
Chris Bolson
Chris Bolson4w ago
In CodePen you can also use sass, you just need to select it from the "settings" icon (cog wheel) in the CSS pane.
peterpumkineaterr
guys you seen the animation of those cards, i don't quite like it and it's not what i had thought. do you guys have any better animation which looks classy ?
ἔρως
ἔρως4w ago
"animation" and "classy" are opposites, in my opinion
peterpumkineaterr
haha how ?
peterpumkineaterr
this is the rough idea what i'm expecting the animation to be or the way this cards should behave
No description
peterpumkineaterr
2 nd is to show how they will hide on each other also this is for smaller screen like 750px
Chris Bolson
Chris Bolson4w ago
My first suggestion would be to not try to animate so many elements, at least not at the same time. For example, in your case I would only animate the size width of the cards. Also, you are currently expanding the width of the child element within the <a> elements. As far as I can tell you don't really need this extra element, you could apply the .wb styles to the <a> element itself and reduce the markup. You would then be able to make better use of the .cards "flex" property to expand the children.
peterpumkineaterr
how this will work on smaller screen i mean text get closer and increases height of card i just don't want it to be messy
Chris Bolson
Chris Bolson4w ago
just more squashed as you haven't added any code or given any indications as to how you would expect it to work on smaller screens. I personally would be tempted to stack them into a single column (I would also use Grid rather than flex but that is another matter)
peterpumkineaterr
so you mean i should replace .wb to a
Chris Bolson
Chris Bolson4w ago
I just did this to remove the extra element:
<a href="luxury.html" class="wb" data-image="1a.png" data-color="luxury">
<a href="luxury.html" class="wb" data-image="1a.png" data-color="luxury">
peterpumkineaterr
i can use grid but i had never used so it will be something else for me you removed .wb div and gave class of wb to a ? am i right ?
Chris Bolson
Chris Bolson4w ago
yes less markup (where possible) is always a good thing
peterpumkineaterr
there's a problem i can't remember why i created wb div and can't even remember where i used it.
Chris Bolson
Chris Bolson4w ago
you could possibly reduce the amount of child elements too but I don't know if you plan to do things with them
peterpumkineaterr
can i make a codepen of full website ? including html and css if you don't mind can you take a look at it if i'm doing anything wrong ?
Chris Bolson
Chris Bolson4w ago
Based on the designs that you posted a few minutes ago, I would probably reduce each card contents to something like this:
<a href="luxury.html" class="wb" data-image="1a.png" data-color="luxury">
<h2>Expensive Luxury.<img src="arrow.svg" alt=""></h2>
<p>Crafting Elegance: Building Expensive Luxury.</p>
</a>
<a href="luxury.html" class="wb" data-image="1a.png" data-color="luxury">
<h2>Expensive Luxury.<img src="arrow.svg" alt=""></h2>
<p>Crafting Elegance: Building Expensive Luxury.</p>
</a>
peterpumkineaterr
<a href="luxury.html">
<div class="wb" data-image="1a.png" data-color="luxury">
<div class="progress-container" data-aos="fade-up" data-aos-duration="800">
<div class="text-container">
<h1 class="cursor">Expensive Luxury.<span><img src="arrow.svg" alt=""></span></h1>
<div class="line"></div>
<div class="year">2023</div>
</div>
<h2 class="cursor">Crafting Elegance: Building Expensive Luxury.</h2>
</div>
</div>
</a>
<a href="luxury.html">
<div class="wb" data-image="1a.png" data-color="luxury">
<div class="progress-container" data-aos="fade-up" data-aos-duration="800">
<div class="text-container">
<h1 class="cursor">Expensive Luxury.<span><img src="arrow.svg" alt=""></span></h1>
<div class="line"></div>
<div class="year">2023</div>
</div>
<h2 class="cursor">Crafting Elegance: Building Expensive Luxury.</h2>
</div>
</div>
</a>
this is how it is the complete code of one card
Chris Bolson
Chris Bolson4w ago
exactly, unless you are actually doing something with all of those divs and elements you really don't need them (based on your design). The code that I posted before should be enough to achive the same result.
peterpumkineaterr
this is how it looks in mobile
No description
peterpumkineaterr
chris let me know what do you think https://codepen.io/kev00690/pen/BaXgqrd
Chris Bolson
Chris Bolson4w ago
As you say, you have issues with your "animations" on the cards block. I say "animations" as there really isn't any animation as such, they are just jumping between states. As I mentioned earlier, I would look at reducing the amount of elements that you are attempting to animate, just the background color and the width (on wider screens would be enough. For example, rather than trying to increase the padding and positioning of the elements within each card, you could give the cards an initial padding and, assuming that you want them to align with the rest of the contents, give them a subtle background color to define the blocks.
Chris Bolson
Chris Bolson4w ago
Something like this
Chris Bolson
Chris Bolson4w ago
This is the link to the CodePen in case you want to see how I did this. Note - There are things in there that I might possibly do differently but I wanted to base it on your existing code where possible.
peterpumkineaterr
differently ? this is already very arranged and minimal
Chris Bolson
Chris Bolson4w ago
you are right, I probably modified it more than I should have 😆
peterpumkineaterr
i can definitely use this insted of long css
Chris Bolson
Chris Bolson4w ago
by the way, I forgot to mentione, I used SVGs for the arrows as I didn't have the paths to your original images. But the same code should work for your images (obviously changing the selector)
peterpumkineaterr
why isn't this text is fully out i'm scratching my head
No description
peterpumkineaterr
trying to understand yes yes i will past my arrow svg code over there if it's too confusing for me
Chris Bolson
Chris Bolson4w ago
Is that from my version? There was a max-width set on that element - I have removed it now from my pen
peterpumkineaterr
ahh it's column yes from your pen yes 20vh i removed it and it is working so i don't need .line and .year now ?
Chris Bolson
Chris Bolson4w ago
actually I have just updated my pen to put the line and year back in as an actual element (rather than the pseudo element that I had for the year) to make it a little clearer. I now have the line as a pseudo element as it is purely decorative.
peterpumkineaterr
chris i'm facing one issue as mobile device doesn't have hover feature so how can i manage this css code ? which part i should use for mobile and which part of css i should put under 700px media query
Chris Bolson
Chris Bolson4w ago
I don't really see why that is an issue??? The only thing hover dependant on smaller screens is the background color of the cards. As, as you say, mobile devices don't have "hover", if you want the cards to show your background colors either you give them that color directly (ie on load) or you add to an "active" class (but as they are links you will only see the color for a few of miliseconds) On larger screens you also have the box resizing and the arrow appearing but that will only be needed on desktop so shouldn't be an issue.
peterpumkineaterr
oh my mistake i understood later haha sorry to disturb you i put the code on it's place how can i make that line to baseline i replaced svg tag with <img src="arrow.svg" alt=""> this but it's not showing when i hover and i changed .wb h2 svg to img oops again it's done
Want results from more Discord servers?
Add your server