Cant use background-color in css - css

so i cant use background-color to change color but if im using background property it works and change the color, why cant just use background-color property?
here's the html file
<div class="flex-row">
<div class="button">4</div>
<div class="button">5</div>
<div class="button">6</div>
<div class="button operator">-</div>
</div>
<div class="flex-row">
<div class="button">1</div>
<div class="button">2</div>
<div class="button">3</div>
<div class="button operator">+</div>
</div>
<div class="flex-row">
<div class="button clear">CE</div>
<div class="button">0</div>
<div class="button equals double">=</div>
</div>
here's the css file
.button{
flex-basis:25%;
font-size: 1.5em;
text-align: center;
padding: 40px;
border: 1px solid black;
background: -webkit-linear-gradient(top, #d2d2d2, #ddd);
cursor: pointer;
}
.operator, .equals, .negative{
background-color: orange;
}

Here's the funny thing: It's working, just not as you'd expect.
The background property always stands in-front of the background-color property. When you say the background color of the element is orange, it works perfectly. But the background property is different, and it covers the background-color of the element. I tried searching for the official term for this, but couldn't find it, so that was my rudimentary explanation. To make this more clear, try setting one of the parameters of the linear gradient to transparent, you'll see that portion of the background reveal the orange background-color. Here's the code that'll make it clearer to you:
.button{
flex-basis:25%;
font-size: 1.5em;
text-align: center;
padding: 40px;
border: 1px solid black;
background: -webkit-linear-gradient(top, transparent, #ddd);
cursor: pointer;
}
.operator, .equals, .negative{
background-color: orange;
}
So no, there's no scalable, simple solution for this, all you can do is change the background of the other elements to orange.

You have to overwrite the gradient.
.button{
flex-basis:25%;
font-size: 1.5em;
text-align: center;
padding: 40px;
border: 1px solid black;
background: -webkit-linear-gradient(top, #d2d2d2, #ddd);
cursor: pointer;
}
.operator, .equals, .negative{
background: -webkit-linear-gradient(top, orange, orange);
}
<div class="flex-row">
<div class="button">4</div>
<div class="button">5</div>
<div class="button">6</div>
<div class="button operator">-</div>
</div>
<div class="flex-row">
<div class="button">1</div>
<div class="button">2</div>
<div class="button">3</div>
<div class="button operator">+</div>
</div>
<div class="flex-row">
<div class="button clear">CE</div>
<div class="button">0</div>
<div class="button equals double">=</div>
</div>

Related

How can I create Side Navigation like with border on left like image?

I want to create side navigation like this in Vue3, with active class.
I want to add border-left like in the image.
Currently I have it like this.
SideBar.vue
<div class="flex flex-col space-y-9 mt-4 -mx-6 ">
<RouterLink v-for="(mu, idx) in menu" :key="idx" class="flex text-[#A09F9F] cursor-pointer "
:to="mu.route">
<img :src="mu.icon" class="w-6 h-6 mr-2 ml-3" />
<span class="text-center text-lg">{{ mu.text }} </span>
</RouterLink>
</div>
router.js
.active class
.active {
color: #3C59A8 !important;
font-weight: bold;
background: linear-gradient(90deg, #E8E9EA 0%, #FAFAFA 100%);
transition: .2s;
border-left: #3C59A8 4px solid;
}
I want make the border as in the first image, rounded border from left side.
Thank you.
I have tried border left, didn't work, tried to add ::before with that it didn't work either.
I would make a new div on the left-hand side of the active link so I could use border-right CSS properties on it
codesandbox
not exactly the same setup as yours, but hopefully it still makes sense conceptually.
<div class="flex flex-col space-y-9 mt-4">
<div
v-for="(mu, idx) in menu"
:key="idx"
class="link cursor-pointer relative"
:to="mu.route"
#click="changeActive(idx)"
>
<div v-if="mu.active" class="active"></div>
<span class="text-center text-lg ml-5">{{ mu.text }} </span>
</div>
</div>
.link {
height: 60px;
display: flex;
align-items: center;
}
.active {
color: #3c59a8 !important;
font-weight: bold;
background: linear-gradient(90deg, #e8e9ea 0%, #fafafa 100%);
height: 100%;
border-right: #3c59a8 8px solid;
border-top-right-radius: 15px 30px;
border-bottom-right-radius: 15px 30px;
position: absolute;
}

Showing article header outside container with background image

I'm working on a specific layout using Bootstrap 5 and attempt to render a tag outside his original container, taking the full page width.
I tried using absolute position on the img tag, however, doing this, footer is going over the tag which is not expected.
More than words, this is what I trying to do
The ideal DOM structure would be as follow :
<article>
<header>
<div>
<img />
<h3 />
</div>
<div class="meta" />
</header>
<div class="content" />
<footer />
</article>
img should get full x-width
img should stay in the overal y position (meaning nothing coming after it - should go over it, like a page footer or anything else)
h3 should be over the img tag
any idea would get a warm welcome, I'm trying to make that small thing working since over a week now :')
you're right
my current best attempt it this, so I split the overall structure in three distinct container box, which sounds like a bit hacky to me - and I have issues when it's rendered on mobile (ie: title is going outside down the box, instead staying stick to the bottom of the image)
<body class="position-relative">
<div class="container-fluid container-lg">
<header class="mt-5">
<nav class="navbar navbar-expand-lg navbar-dark mt-5 mb-3"></nav>
</header>
</div>
<main class="mt-5 mb-3" role="main">
<section>
<article>
<header>
<div class="go-article-banner d-flex position-relative">
<img style="object-fit: cover;position: absolute;height: 300px;left: 0;right: 0;/*! width: 200%; */" class="w-100" src="...">
<div class="container-fluid container-lg position-relative">
<div class="position-absolute bottom-0 start-0 right-0" style="background: rgba(0, 0, 0, 0.4);">
<h3 class="display-3 p-4">The War of the Worthies: the spectre of Cardan’s aggression</h3>
</div>
</div>
</div>
</header>
<div class="container-fluid container-lg"></div>
<footer class="container-fluid container-lg"></footer>
</article>
</section>
</main>
<div class="container-fluid container-lg">
<footer>
<div class="go-streaming-news d-none d-sm-block mb-4">
<div class="row">
<div class="col col-sm-4 col-lg-3 col-xl-2 d-flex justify-content-between text-uppercase" style="background-color: var(--bs-primary); padding: .5rem 1rem;">
<span>Breaking News</span>
<span style="border-right: solid 2px rgb(50, 67, 100)"></span>
<span>21:03</span>
</div>
<div class="col col-sm-8 col-lg-9 col-xl-10 marquee-wrapper">
<div class="marquee"><div style="width: 100000px; animation: 9.64667s linear 0s infinite normal none running marqueeAnimation-39418180; transform: translateX(1084px);" class="js-marquee-wrapper"><div class="js-marquee" style="margin-right: 0px; float: left;">
<ul class="list-inline m-0 p-0">
<li class="list-inline-item">Some news</li>
<li class="list-inline-item">Another news</li>
<li class="list-inline-item">Yet Another news</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</footer>
</div>
</body>
However, the render is good https://imgur.com/a/9wBse0Q
My previous attempt was that one, and with that, the marquee box is going inside the article banner. This, and the title is going outside the image which is rendered using a after anchor.
<body class="position-relative customize-support">
<div class="container-fluid container-lg">
<header class="mt-5">
<nav class="navbar navbar-expand-lg navbar-dark mt-5 mb-3"></nav>
</header>
<main class="mt-5 mb-3" role="main">
<section>
<article>
<header>
<div class="go-article-banner"></div>
<div class="d-flex">
<h3 class="display-3">Change of course for Eskari Industries</h3>
</div>
</header>
<div></div>
<footer></footer>
</article>
</section>
</main>
<footer>
<div class="go-streaming-news d-none d-sm-block mb-4">
<div class="row">
<div class="col col-sm-4 col-lg-3 col-xl-2 d-flex justify-content-between text-uppercase" style="background-color: var(--bs-primary); padding: .5rem 1rem;">
<span>Breaking News</span>
<span style="border-right: solid 2px rgb(50, 67, 100)"></span>
<span>21:03</span>
</div>
<div class="col col-sm-8 col-lg-9 col-xl-10 marquee-wrapper">
<div class="marquee">
<div style="width: 100000px; animation: 9.64667s linear 0s infinite normal none running marqueeAnimation-33044180; transform: translateX(1084px);" class="js-marquee-wrapper">
<div class="js-marquee" style="margin-right: 0px; float: left;">
<ul class="list-inline m-0 p-0">
<li class="list-inline-item">Some news</li>
<li class="list-inline-item">Another news</li>
<li class="list-inline-item">Yet Another news</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</footer>
</div>
</body>
/*
Theme Name: Galaxy One
Theme URI: https://galaxyone.news
Author: Loic Leuilliot
Author URI: https://github.com/warlof
Description: Galaxy One Gazette default template
Tags: newspaper, rising constellation, game, news
Version: 0.1
Requires at least: 5.0
Tested up to 5.4
Requires PHP: 7.0
License: GNU General Public License v2 or Later
License URI: https://www.gnu.org/Licenses/gpl-2.0.html
Text Domain: galaxyone
*/
#font-face {
font-family: "Gtek Technology";
src: url("./assets/fonts/Gtek Technology.ttf") format('truetype');
font-weight: bold;
}
header h1 {
font-size: calc(1.375rem + 3vw);
font-family: "Gtek Technology", sans-serif;
margin-bottom: 0;
border-bottom: solid 4px var(--bs-primary);
}
.navbar-nav {
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
}
.navbar-nav > li {
flex-grow: 1;
}
.navbar-nav .nav-link {
text-align: center;
text-transform: uppercase;
padding: .7rem 1rem;
border-top: 1px solid var(--bs-primary);
border-bottom: 1px solid var(--bs-primary);
}
.navbar-dark .navbar-nav .nav-link:hover, .navbar-dark .navbar-nav .nav-link:focus {
color: var(--bs-primary);
}
.navbar-dark .navbar-nav .show > .nav-link, .navbar-dark .navbar-nav .nav-link.active {
color: #fff;
background-color: var(--bs-primary);
}
.go-news .card-img-top {
height: 250px;
object-fit: cover;
object-position: 50% 0;
}
.go-news .stretched-link:hover::after {
background: #282c34dd url("./assets/img/plus-circle.svg") center no-repeat;
background-size: 50%;
transition: background-color 0.5s ease;
}
.go-category-link {
border-radius: 0;
border: none;
padding: 0.5rem;
text-transform: uppercase;
text-decoration: none;
}
.go-category-link.category-sport {
background-color: var(--bs-primary);
}
.go-category-link.category-politics {
background-color: var(--bs-danger);
}
.go-category-link.category-financial, .go-category-link.category-people {
background-color: var(--bs-warning);
}
.go-category-link.category-miscellaneous {
background-color: var(--bs-success);
}
.go-category-link.category-sciences {
background-color: var(--bs-secondary);
}
.page-item {
margin-right: 20px;
}
.page-item:last-child {
margin-right: 0;
}
.page-item:first-child .page-link {
border-radius: 0;
}
.page-item:last-child .page-link {
border-radius: 0;
}
.page-item.disabled .page-link {
background-color: var(--bs-primary);
border-color: var(--bs-primary);
color: #fff;
}
.page-link {
background-color: transparent;
border-color: var(--bs-primary);
color: rgba(255,255,255,0.55);
}
.page-link:hover {
color: var(--bs-primary);
}
.page-link.dots:hover {
background-color: transparent;
border-color: var(--bs-primary);
color: rgba(255,255,255,0.55);
cursor: default;
}
.go-article-banner {
height: 300px;
}
.go-article-banner::after {
background: #333 url('...') no-repeat center;
background-size: cover;
content: "";
position: absolute;
height: 300px;
left: 0;
right: 0;
}
.go-streaming-news .marquee-wrapper {
background-color: #4472c455;
padding: 0.5rem;
}
.go-streaming-news .marquee {
overflow: hidden;
}
.go-streaming-news .marquee .list-inline-item {
border-right: solid 3px var(--bs-primary);
margin: 0;
padding: 0 0.5rem;
}
.go-streaming-news .marquee .list-inline-item:last-child {
border-right: none;
}
Well, I finally figure a way to do it properly (I think so at least).
Overall reference is this blog post https://css-tricks.com/full-width-containers-limited-width-parents/
I'm using the very last alternative as detailed by "No calc() needed" which is probably the more flexible solution.
First, here is the global DOM structure
<div class="container-fluid container-lg">
<header>
<nav></nav>
</header>
<article>
<header>
<div class="go-article-header">
<div class="go-article-banner" style="background-image: url('...');"></div>
<div class="go-article-title-wrapper">
<h3 class="display-3 m-0">Article title</h3>
</div>
</div>
</header>
<div class="go-article-content">
<p>...</p>
</div>
<footer></footer>
</article>
<footer></footer>
</div>
We have a unique container which is covering the overall page
Inside this container, there are a global header and footer with navigation inside the header
Between both, we have an article, container its own header and footer
The header is containing a few wrapper for extra styling (like background under title, and so on) - I also switched from img tag to a background in order to be able to use cover property. But here again, it's much more a design choice
Now, the styling :
.go-article-header {
height: 300px;
position: relative;
}
.go-article-banner {
position: relative;
left: 50%;
right: 50%;
width: 100vw;
height: 100%;
margin-left: -50vw;
margin-right: -50vw;
background-image: url("assets/img/eskari.png");
background-color: #333;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
.go-article-title-wrapper {
background-color: rgba(0, 0, 0, 0.6);
position: absolute;
left: 0;
right: 0;
bottom: 0;
padding: 1rem;
}
Everything is happening with the .go-article-banner class which is first aligning the tag (using the left and right properties) and then make it start outside the box (using the margin properties). Last but not least, the width property using view width metric is ensuring the tag will use the full screen width.
Regarding title, we just need to fix it left/right/down using parent container. This is done with the .go-article-title-wrapper class.
Here is the final render

White space between medium-7 and medium-5 on the same line with Foundation

I need some help with some simple styling of two boxes I'm trying to make. I need to have some white space between them. I am using foundation, and have made one box which should fill medium-7 and another that will fill medium-5.
I just need some white space between them, but can't seem to do it.
Code:
<div class="main-container">
<div class="row gutter">
<div class="column small-12 medium-7 color border-right">
<div class="row">
<div class="column small-12">
</div>
</div>
</div>
<div class="column small-12 medium-5 color border-left">
<div class="row">
<div class="column small-12">
</div>
</div>
</div>
</div>
</div>
Css
.color {
background-color: #F2F2F2;
padding-top: 0.8333rem;
padding-bottom: 0.8333rem;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.05);
border: 1px solid #CCC;
}
.border-left {
border-left: 12px solid #ffffff;
}
.border-right {
border-right: 12px solid #ffffff;
}
Have already tried with padding-left and padding-right, but nothing happens.
Also have tried with the border-left and right as you see, but then the box-shadow and border from the color class looks weird :(
What can I do here? any tricks?
Image where only color class is applied:
Image where border-left and right and color class is applied:
Add the following CSS to get the required output::
.border-right {
border-right: 12px solid #ffffff;
margin-right: 10px;
}
.color {
background-color: #F2F2F2;
padding-top: 0.8333rem;
padding-bottom: 0.8333rem;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.05);
border: 1px solid #CCC;
display: inline-block;
width: 48%;
}
.row.gutter{
width: 100%;
text-align: center;
}

CSS : Button is shifing bit downward as compared to label

Using
github link
HTML Code
<div class="col-md-12">
<div class="col-md-2">
Processing
</div>
<div class="col-md-4">
<button class="btn btn-primary">Hello</button>
</div>
</div>
.btn {
position: relative;
padding: 8px 30px;
border: 0;
margin: 10px 1px; cursor: pointer;
border-radius: 2px;
text-transform: uppercase;
text-decoration: none;
color: rgba(255, 255, 255, 0.84);
transition: background-color 0.2s ease, box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1); outline: none !important; }
You can clearly notice that button is going down as compared to label.
Any CSS Fix? temporary may be??
A middle vertical-align and a display of inline-block should fix this.
Booply
<div class="col-md-12">
<div class="col-md-2 vcenter">
Processing
</div>
<div class="col-md-4 vcenter">
<button class="btn btn-primary">Hello</button>
</div>
</div>
.vcenter {
display: inline-block;
vertical-align: middle;
float: none;
}

Multiple Divs / Classes On an Opaque Background

My goal (and the question of how-to) is to have an opaque / white background with black fields over the opaque area to serve as content holders. Here is what I have now:
/* translucent background*/
.background
{
width:950px;
height:1024px;
margin: 9px auto 10px;
background-color:#ffffff;
opacity:0.35;
filter:alpha(opacity=35); /* For IE8 and earlier */
border-radius: 15px;
-moz-border-radius: 15px;
z-index:0;
}
/*content wrapper*/
.content
{
font-family: Arial;
font-size: 11px;
width:950px;
height:1024px;
margin: 9px auto 10px;
border-radius: 15px;
-moz-border-radius: 15px;
z-index:1;
}
/*one of three content fields*/
.anounce_bar
{
font-family: Arial;
font-size: 16px;
width:940px;
height:225px;
float: left;
border: 5px 5px 5px 5px;
background-color: black;
border-radius: 15px;
-moz-border-radius: 15px;
z-index:2;
}
<div class="background"></div>
<div class="content">
<!--Top announcement bar-->
<div class="anounce_bar">
</div>
<!--Left side nav bar-->
<div class="nav" style="height: 1024px; ">
</div>
<!--Right side content window-->
<div class="content_window">
</div>
</div>
Right now its showing the anounce_bar below the translucent background.. how do I get the bar (and subsequent nav & content_window) to go on top of .background?
Note: I have other content, including a top 'masthead' image and a background JPG that might be screwing with this.
Any help would be GREATLY appreciated.
Update:
This was an issue with opacity inheritance - the work around I used is described very well here
'background' class became #background without any opacity, and a new item was added:#background .transparency with absolute positioning and opacity.
<div id="background">
<div class='transparency'></div>
/*OTHER STUFF*/
</div>
Change the order
<div class="anounce_bar"></div>
<div class="background"></div>
That should work.
<div class="background">
<div class="content">
<!--Top announcement bar-->
<div class="anounce_bar" style="color: white">Anounce Bar</div>
<!--Left side nav bar-->
<div class="nav" style="height: 24px; width: 940px; background-color: green; float:left;">Nav</div>
<!--Right side content window-->
<div class="content_window" style="height: 24px; width: 940px; background-color: yellow; float:left;">Content Window</div>
</div>
</div>
Sample Code

Resources