I have some dots (DIVs) lined up which link to each section of a single page website. They're in a fixed position so they scroll down as the user scroll down. However when I get to a section with a lighter background you can't see them, highlighted in the picture below:
What I'd like is for them to remain white but as the user scroll down, for the dots to change to dark grey instead. I do have multiple sections with lighter background so I need the dots to be able to "tell" when they're on a light background.
Is this even possible at all?
My HTML is:
<div class="pagination_dots">
<div class="circle current"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
My CSS is:
.pagination_dots {
position: fixed;
top: 50%;
left: 15px;
transform: translateY(-50%);
display: flex;
flex-direction: column;
z-index: 20;
}
.pagination_dots .circle {
margin-bottom: 14px;
border-radius: 50%;
width: 9px;
height: 9px;
background: #fff;
position: relative;
cursor: pointer;
}
.pagination_dots .circle:after {
content: '';
display: inline-block;
border: 1px solid rgba(196,163,105, 0);
border-radius: 50%;
width: 18px;
height: 18px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transition: all 0.5s;
}
.pagination_dots .circle:hover:after,
.pagination_dots .circle.current:after {
border: 1px solid rgba(196,163,105, 1);
}
You can use mix-blend-mode CSS -> difference value on the .pagination_dots element
From MDN, the mix-blend-mode CSS property sets how an element's content should blend with the content of the element's parent and the element's background.
.section {
min-height: 25rem;
}
.section-black {
background: #272526;
}
.section-grey {
background: #F1F1F1;
}
.pagination_dots {
position: fixed;
top: 50%;
left: 15px;
transform: translateY(-50%);
display: flex;
flex-direction: column;
z-index: 20;
mix-blend-mode: difference;
}
.pagination_dots .circle {
margin-bottom: 14px;
border-radius: 50%;
width: 9px;
height: 9px;
background: #fff;
position: relative;
cursor: pointer;
}
.pagination_dots .circle:after {
content: '';
display: inline-block;
border: 1px solid rgba(196, 163, 105, 0);
border-radius: 50%;
width: 18px;
height: 18px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transition: all 0.5s;
}
.pagination_dots .circle:hover:after,
.pagination_dots .circle.current:after {
border: 1px solid rgba(196, 163, 105, 1);
}
<div class="section section-black">
</div>
<div class="section section-grey">
</div>
<div class="section section-black">
</div>
<div class="pagination_dots">
<div class="circle current"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
Related
I am using :before to create a black circle (which should display white text exactly centered within, can't work out why it isn't white) and :after to display a dashed line (as seen). I'd like the black circle (with text inside it) to sit horizontally level with the input but I've been having issues with it as it also creates a big gap between it & the after dashed line. I've played around margin but I don't want to push elements above too far away.
.progress-container {
display: flex;
position: relative;
}
.progress-indicator {
position: relative;
display: inline-block;
margin-bottom: 40px;
color: #fff;
}
.progress-indicator::before {
content: "";
width: 22px;
height: 22px;
background: #000;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
}
.progress-indicator::after {
content: "";
height: 85px;
border: 2px dashed #a9b4b8;
position: absolute;
left: 50%;
top: 49px;
transform: translateX(-50%);
margin-bottom: 10px;
}
.input-container {
display: flex;
align-items: center;
}
.input-wrapper {
border: 1px solid #ced4da;
border-radius: 2px;
overflow-y: hidden;
padding: 0.375rem 1.75rem 0.375rem 0.75rem;
margin-left: 30px;
}
<div class=progress-container>
<div class="progress-indicator">1</div>
<div class="input-container">
<div class="input-wrapper">
<div>Input</div>
</div>
</div>
</div>
Caution: you have a typo in your .progess-container selector correct: .progress-container
Edited your CSS:
.progress-container {
display: flex;
flex-direction: row;
align-items: center;
position: relative;
}
.progress-indicator {
position: relative;
display: inline-block;
color: #fff;
}
.progress-indicator::before {
content: "";
width: 22px;
height: 22px;
background: #000;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
z-index: -1;
}
.progress-indicator::after {
content: "";
height: 85px;
border: 2px dashed #a9b4b8;
position: absolute;
left: 50%;
transform: translateX(-50%);
margin-bottom: 10px;
z-index: -2;
}
.input-container {
display: flex;
align-items: center;
}
.input-wrapper {
border: 1px solid #ced4da;
border-radius: 2px;
overflow-y: hidden;
padding: 0.375rem 1.75rem 0.375rem 0.75rem;
margin-left: 30px;
}
<div class=progress-container>
<div class="progress-indicator">1</div>
<div class="input-container">
<div class="input-wrapper">
<div>Input</div>
</div>
</div>
</div>
I've stuck with styling issues. What I'm trying to reach is make sure that every single h3 tag has same distance between bottom border of his container (pink border) and bottom border of his parent (picture bottom border). Now it looks like this:
Both of them has same css, difference is only with amount of text.
HTML:
<div class="col-6">
<a href='{{link}}' style='background-image: url("{{image}}")' class="histories__image">
<div class="histories__text">
<h3>{{title}}</h3>
</div>
<div class="histories__underline"></div>
</a>
</div>
CSS:
.histories {
margin-bottom: 100px;
&__image {
height: 41vh;
margin-top: 33px;
display: block;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
transition: filter 1s;
&:hover{
filter: brightness(80%);
}
&:hover .histories__text{
bottom: 15px;
}
&:hover .histories__underline{
opacity: 1;
left: 0;
width: 70%;
}
}
&__text {
text-align: center;
display: block;
position: absolute;
width: 100%;
bottom: 0px;
left: 50%;
transform: translate(-50%, -50%);
transition: bottom .3s;
color: white;
border: 1px solid pink;
}
&__underline {
position: absolute;
display: block;
bottom: 10%;
width: 0%;
left: 50%;
margin-left: 15%;
background-color: white;
height: 1px;
opacity: 0;
transition: width .3s, left .3s;
}
}
You can try using translate like this to center your content with the same class.
.histories__text{
width: 100%;
}
.histories__text h3{
transform: translate(50%,50%);
}
<div class="col-6">
<a href='{{link}}' class="histories__image">
<div class="histories__text">
<h3>Your Text</h3>
</div>
<div class="histories__underline"></div>
</a>
</div>
I am building a webpage with cards arranged in a grid.
However, I would like my cards to have a unique shape, rather than just being rectangles. The shape I would like them to be is the shape of a manilla folder (pictured below)
Is there any relatively simply way to make a div with this shape?
Here is a start using only html and css:
body {
padding: 50px;
}
div {
position: relative;
z-index: 1;
white-space: nowrap;
}
div .slant {
position: relative;
display: inline-block;
color: inherit;
text-decoration: none;
margin: 0 -14px -4px;
width: 40px;
}
div .slant::before,
main {
border: 0.2em solid #000;
background: #000;
}
div .slant::before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0.5em;
left: 0;
z-index: -1;
border-bottom: none;
border-radius: 5px 5px 0 0;
background: #000;
transform: perspective(5px) rotateX(2deg);
transform-origin: bottom;
}
div.left .slant {
padding: 1.5em 2em 1em 1em;
}
div.left .slant::before {
transform-origin: bottom left;
}
main {
display: block;
margin: -8px 0 30px -14px;
padding: 1em;
border-radius: 0 5px 5px 5px;
width: 200px;
height: 300px;
}
<div class="left">
<div class="slant"></div>
</div>
<main>
</main>
It took me about 10 minutes just to do that, so if you have the motivation to improve it, feel free to do so. It is possible to do it with divs and positioning with CSS. It's just a matter of playing with z-index and shapes, but unless you just wan't to impress yourself for achieving it, the easiest way is to create a background image and move your html content over it.
I am not the best front-end programmer either so don't be arshe! I'm sure someone else could improve it even better with outline borders and stuff.
div#panel {
position: absolute;
border: 3px solid black;
border-radius: 10px;
width: 200px;
height: 200px;
background-color: white;
top: 50%;
left: 50%;
z-index: 3;
transform: translate(-50%, -50%);
}
div#box {
position: absolute;
border: 3px solid red;
z-index: 0;
border-radius: 10px;
width: 200px;
height: 200px;
top: 48.5%;
left: 50%;
z-index: ;
transform: translate(-50%, -50%);
}
div#box2 {
position: absolute;
border: 3px solid red;
border-radius: 10px;
width: 80px;
height: 200px;
background-color: white;
top: 47%;
left: 46.9%;
z-index: 1;
transform: translate(-50%, -50%);
}
<div id="panel"></div>
<div id="box">
<p style="padding-left: 5px;"> Some text here</p>
</div>
<div id="box2"></div>
You can use this shape as the background-image of the card. Remove the card default property like background-color, box-shadow...
HTML:
<div class="main-class">
<div class="card">
.....
</div>
</div>
CSS:
.main-class .card{
background-image: url("path");
background-repeat: no-repeat;
background-size: cover;
background-color: transparent;
box-shadow: none;
}
Im having a problem with a :before element (a left pointing triangle) getting a small line through the middle of it when I transform: scale on :hover I'm not sure what is causing this.. I have seen the same effect on other websites and it doesn't happen.
Any help would be appreciated
.container{
display: flex;
height: 45vw;
width: 100%;
background: black;
}
.image{
background: blue;
width: 50%;
height: 100%
}
.text{
background: yellow;
width: 50%;
height: 100%
}
.text:before{
content: '';
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
top: 50%;
left: -17px;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid yellow;
}
.text:hover{
transform: scale(1.1);
transition: 0.4s;
}
<div class="container">
<div class="image">
</div>
<div class="text">
</div>
</div>
view on jsFiddle: https://jsfiddle.net/wap184pe/1/
This workaround essentially makes a triangle twice the size of the triangle you have and hides half of it, so the thin border is not visible. Check out this related issue with rendering triangles as borders in Firefox.
.container{
display: flex;
height: 45vw;
width: 100%;
background: black;
}
.image{
background: blue;
width: 50%;
height: 100%
}
.text{
background: yellow;
width: 50%;
height: 100%
}
.text:before{
content: '';
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
top: 35%;
height: 0;
width: 0;
border: 36px solid transparent;
border-right: 0;
border-top-color: yellow;
transform: rotate(225deg);
}
.text:hover{
transform: scale(1.1);
transition: 0.4s;
}
<div class="container">
<div class="image">
</div>
<div class="text">
</div>
</div>
If you use the arrow at generator at http://www.cssarrowplease.com, you can save yourself the trouble
In the template, I need to implement overlay images on the menu, but I would like to leave with the menu items available to a clique completely, not partially.
Now it implemented so that only the upper part of button is available https://arthurmiko.github.io/shadows_portfolio/
.elem {
display: inline-block;
width: 100px;
height: 100px;
background: #777;
transition: .3s;
}
.elem:hover {
cursor: pointer;
background: #f77;
}
.higher-box {
position: relative;
margin-top: -50px;
width: 308px;
height: 100px;
background: rgba(0, 0, 255, .9);
z-index: 1;
}
<div class="lower-box">
<div class="elem"></div>
<div class="elem"></div>
<div class="elem"></div>
</div>
<div class="higher-box"></div>
Is it possible to somehow leave the gray blocks are available for the cursor, in the overlapping area of blue block?
If you can remove the cursor actions for higher-box you can do it with .higher-box { pointer-events: none }
.elem {
display: inline-block;
width: 100px;
height: 100px;
background: #777;
transition: .3s;
}
.elem:hover {
cursor: pointer;
background: #f77;
}
.higher-box {
position: relative;
margin-top: -50px;
width: 308px;
height: 100px;
background: rgba(0, 0, 255, .9);
z-index: 1;
pointer-events: none;
}
<div class="lower-box">
<div class="elem"></div>
<div class="elem"></div>
<div class="elem"></div>
</div>
<div class="higher-box"></div>
You can use a pseudoelement, assuming there is no previous stacking context:
HTML
<div class="covered"></div>
<div class="covering"></div>
CSS
.covered{
width: 200px; height: 200px;
background: red;
position: relative;
}
.covered:hover{
background-color: green;
}
.covering{
width: 200px; height: 200px;
background: blue;
position: relative;
top: -100px;
}
.covered:before{
content: "";
display: block;
position: absolute;
z-index: 300;
width: 100%; height: 100%;
}
http://codepen.io/anon/pen/KryBBr