Is there a way to style a row of divs with multiple box-shadows so they look like the box-shadow is on wrapping element?
Due to 3rd party lib limitation I cannot put a box-shadow on a parent element.
Here is the snippet - I cannot really get rid of the spaces between box-shadows.
.container {
/* THIS ELEMENT CANNOT HAVE BOX-SHADOW*/
display: flex;
flex-direction: row;
}
.child {
position: relative;
background-color: grey;
width: 160px;
height: 90px;
box-shadow: 0 -5px 5px -5px #333, 0 5px 5px -5px #333;
}
<div class="container">
<div class="child">1</div>
<div class="child">2</div>
<div class="child">3</div>
</div>
you could apply the shadow to container::before and keep the pseudoelement under the children.
.container {
/* THIS ELEMENT CANNOT HAVE BOX-SHADOW */
display: flex;
flex-direction: row;
position: relative;
width: max-content;
}
.container::before {
content: "";
position: absolute;
z-index: 0;
top: 0; left: 0; right: 0; bottom: 0;
box-shadow: 0 -5px 5px -5px #333, 0 5px 5px -5px #333;
}
.child {
position: relative;
background-color: grey;
width: 160px;
height: 90px;
}
<div class="container">
<div class="child">1</div>
<div class="child">2</div>
<div class="child">3</div>
</div>
Related
This question already has an answer here:
How to create uneven rounded sides on a div?
(1 answer)
Closed 10 months ago.
I'm trying to create a web element like this, but am having trouble figuring out how to make a curved border between two divs. I understand the functionality of border-radius (very bad implementation in codepen below), bit wanted to see if anyone had ideas on how to implement the picture above? I thought about having a border-radius with a much larger radius, then hiding overflow, but not sure if that makes sense.
https://codepen.io/unsure-of-name/pen/LYeBdbX
.circle {
height: 100px;
width: 100px;
background-color: #eee;
border-radius: 100px;
box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.2), 0 0px 20px 0 rgba(0, 0, 0, 0.19);
display: inline-block;
vertical-align: top;
position: relative;
z-index: 2;
}
.bar {
display: inline-block;
margin-top: 25px;
background-color: #eee;
margin-left: -50px;
padding-left: 50px;
height: 50px;
text-align: center;
positive: relative;
z-index: 1;
}
.bar div:nth-child(1) {
background-color: red;
border-radius: 10px;
}
.bar div:nth-child(2) {
background-color: #bbb;
}
.bar div:nth-child(3),
.bar div:nth-child(4) {
background-color: #eee;
border-right: 1px solid black;
}
.bar div {
display: inline-block;
vertical-align: middle;
text-align: center;
line-height: 50px;
}
.row {
}
.row > div {
}
<div class='container'>
<div class='row'>
<div class='circle'>
</div>
<div class='bar'>
<div>
Group 1
</div>
<div>
Description
</div>
<div>
Cell 1
</div>
<div>
Cell 2
</div>
</div>
</div>
<div class='row'>
<div class='circle'>
</div>
<div class='bar'>
<div>
Group 1
</div>
<div>
Description
</div>
<div>
Cell 1
</div>
<div>
Cell 2
</div>
</div>
</div>
</div>
Thanks!
That's some very confusing css you have written. The css below will get you what you want. You still have to organize the rest of it. Hope this helps.
.row{
display: flex;
align-items: center;
}
.bar {
display: inline-block;
background-color: #eee;
margin-left: -50px;
padding-left: 50px;
height: 50px;
display: flex;
text-align: center;
positive: relative;
z-index: 1;
}
.bar div{
padding: 0 10px;
width: 100px;
}
.bar div:nth-child(1) {
position: relative;
background: red;
color: black;
height: 50px;
}
.bar div:nth-child(1)::before{
content: '';
width: 20px;
height: 100%;
position: absolute;
bottom: 0;
right: -5px;
background: red;
border-radius: 100%;
}
You can try using ellipse to define the how 'curvy' the side should look
#box1 {
background: red;
width: 10rem;
height: 3rem;
padding: 0.5rem;
clip-path: ellipse(10rem 7.5rem at left);
}
.wrapper {
background: blue;
width: 20rem;
}
<div class="wrapper">
<div id="box1">
</div>
</div>
I am creating a site in order to monitor employees, and there are many interfaces within the site, and from these interfaces there is an interface to add a project, which is the interface shown in the image and as shown in the image there are two sections in the interface, the first part is colored in white and the second section is colored in blue.
How can I create shadow between the two sections?
<template>
<v-app>
<div class="mainPage">
<!-- right section -->
<div class="split left">
<div class="left_body_content">
<div class="left-body-content_logo">
<img class="logo" src="../../../../src/assets/logo_base.png" />
</div>
<div class="left-body-content_illustrationImage">
<v-img src="../../../../src/assets/create.svg"></v-img>
</div>
</div>
</div>
<div class="split-1 right">
<div class="right_body_content">
<div class="right_body_content_text">
<div class="text">
<h1>Create project</h1>
</div>
</div>
<div class="right_body_content_field">
<v-text-field
label="Project Name"
v-model="project_Name"
color="#5f48ea "
class="field"
>{{ project_Name }}
</v-text-field
>
</div>
<div class="right_body_content_button">
</div>
</div>
</div>
</div>
</v-app>
</template>
<style scoped>
.mainPage {
justify-content: flex-start;
align-items: flex-start;
position: relative;
width: 100%;
height: auto;
padding: 0;
margin: 0;
}
.split {
height: 100%;
width: 66%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
}
.left_body_content {
display: flex;
width: 100%;
}
.left {
left: 0;
background-color: #fff;
}
.left-body-content_logo {
display: flex;
width: 18%;
padding-left: 2rem;
}
.logo {
display: flex;
width: 100%;
z-index: -1;
}
.left-body-content_illustrationImage {
display: flex;
justify-content: center;
align-content: center;
align-items: center;
background-size: cover;
background-position: center;
z-index: -1;
width: 90%;
height: 100%;
position: absolute;
padding-top: 7rem;
padding-left: 5rem;
}
.split-1 {
height: 100%;
width: 34%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 2rem;
}
.right_body_content {
display: flex;
width: 100%;
height: 100%;
}
.right_body_content_text {
display: flex;
justify-content: flex-start;
align-items: center;
text-align: center;
width: 90%;
height: 50%;
padding-left: 2rem;
}
.text {
display: flex;
font-family: Aviliator;
color: #5f48ea;
}
.right_body_content_field{
display: flex;
justify-content: flex-start;
align-items: center;
position: fixed;
width: 25%;
height: 100%;
padding-left: 2.5rem;
}
.field{
display: flex;
width: 40%;
height: 30%;
}
.right {
right: 0;
background-color: blue;
}
</style>
Add class shadow to the div having class split-1 and define shadow class in styles as
.shadow{
-webkit-box-shadow: -3px 0px 0px #ccc; /* Safari 3-4, iOS 4.0.2 - 4.2,
-moz-box-shadow: -3px 0px 0px #ccc; /* Firefox 3.5 - 3.6 */
box-shadow: -3px 0px 0px #ccc; /* IE 9, Firefox 4+, Chrome 6+ */
}
this will add a shadow of 3px to the left of the div with class shadow
You can read more about box-shadow here - https://css-tricks.com/almanac/properties/b/box-shadow/
Here I have created two div's
and for shadow using:
box-shadow: /* offset-x | offset-y | blur-radius | spread-radius | color */
.first {
background-color: rgba(0, 0, 0, 0);
width: 500px;
height: 100px;
box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.2);
margin: 5px;
}
.second {
background-color: rgba(0, 0, 255, 1);
width: 500px;
height: 100px;
box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.2);
}
<div>
<div class="first">
</div>
<div class="second">
</div>
</div>
I'm trying to create a circle as an ::after pseudo element, which resizes automatically depending on its content.
.container {
display: flex;
flex-direction: row;
}
#dividerHost2 #left {
flex: 1 1 auto;
background-color: yellowgreen;
height: 200px;
}
#dividerHost2 #right {
flex: 1 1 auto;
background-color: dodgerblue;
}
#dividerHost2 .divider {
background-color: white;
margin: 0px;
width: 6px;
font-weight: 800;
}
.divider.vertical {
--divider-color: transparent;
display: inline-flex;
width: 1px;
border-left: 1px solid rgb(var(--divider-color));
margin: 0px 2px 0px 2px;
overflow: show;
}
.divider.vertical.title::after {
flex: 0 0 auto;
align-self: center;
border-radius: 50%;
content: "OR";
padding: 9px 8px 11px 8px;
background-color: white;
color: black;
transform: translateX(-44%);
z-index: 10;
}
<div id="dividerHost2" class="container">
<div id="left" class="container" style="flex-direction: row;"></div>
<div id="divider3" class="divider vertical title"></div>
<div id="right" class="container" style="flex-direction: row;"></div>
</div>
That gives a pretty nice result so far:
JSFiddle https://jsfiddle.net/jsnbtmh3/
However, with longer text the circle turns into an oval:
How to make the circle auto resize depending on its content?
Here is a trick using radial-gradient. The idea is to keep the element full height and color it using circle closest-side which will always create a circle that will start from the center and expand to the closest sides (left and right one)
I simplified the code to keep only the relevant part:
.container {
display: flex;
flex-direction: row;
margin:10px;
}
.left {
flex: 1 1 auto;
background-color: yellowgreen;
height: 200px;
}
.right {
flex: 1 1 auto;
background-color: dodgerblue;
}
.divider {
background-color: white;
width: 6px;
font-weight: 800;
display: flex;
justify-content: center;
}
.divider::after {
display: flex;
align-items: center;
flex: 0 0 auto;
content: attr(data-text);
padding: 0 8px;
background: radial-gradient(circle closest-side, white 98%, transparent 100%);
z-index: 10;
}
<div class="container">
<div class="left "></div>
<div class="divider" data-text="OR"></div>
<div class="right "></div>
</div>
<div class="container">
<div class="left "></div>
<div class="divider" data-text="longer"></div>
<div class="right "></div>
</div>
<div class="container">
<div class="left "></div>
<div class="divider" data-text="even longer"></div>
<div class="right "></div>
</div>
Don't put actual content in the pseudo-element especially as this is actually "content" rather than styling, rather use the pseudo-element to create a background circle using the padding/aspect ratio trick.
body {
text-align: center;
}
.divider {
margin: 3em;
display: inline-block;
position: relative;
padding: 1em;
font-weight: bold;
}
.divider:after {
content: "";
position: absolute;
width: 100%;
padding-top: 100%;
background: lightblue;
border-radius: 50%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: -1;
}
<div class="divider">OR</div>
<div class="divider">LONG TEXT</div>
With the below code, I am trying to make an overlay for a "progress bar" with text, I need the flex to make it responsive,
BUT the only way I know to make an overlay is to use things like fixed or absolute position, which breaks the layout, is there a way to keep it responsive and have an overlay with dynamic width (for displaying progress).
.master{
display: flex;
}
.item{
border-right: 1px solid black;
padding-right: 5px;
display: inline-block;
text-align: center;
padding: 15px 0;
flex-grow: 1;
flex-basis: 0;
}
<div style='border:1px solid black;margin: 0 auto;'>
<div class='master'>
<span class="item">a</span>
<span class="item">b</span>
<span class="item">c</span>
</div>
<div id='overlay' style='background-color:red;opacity:0.7;width:100%;height:100%;'></div>
</div>
Absolute position will not break the layout...assuming you have set the positioning context on the parent?
.parent {
position: relative;
}
.master {
display: flex;
}
.item {
border-right: 1px solid black;
padding-right: 5px;
display: inline-block;
text-align: center;
padding: 15px 0;
flex-grow: 1;
flex-basis: 0;
}
#overlay {
position: absolute;
background-color: red;
opacity: 0.7;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
<div class="parent">
<div class="master">
<span class="item">a</span>
<span class="item">b</span>
<span class="item">c</span>
</div>
<div id="overlay"></div>
</div>
I am trying to achieve the box-shadow inside the right-border, currently everything is working fine except the shadow is getting display outside the right border. Following is the js-fiddle sample code I have tried...
http://jsfiddle.net/5y1guk6d/1/
HTML:
<div class="header">
<div class="header-bar">
<h1 class="title">Page title</h1>
</div>
</div>
<div class="main">
<div class="left-bar">
<div class="menu">
Menu Content
</div>
</div>
<div class="content">
Main content area
</div>
</div>
CSS:
.header {
width: 100%;
height: 40px;
top: 0;
color: white;
}
.header-bar {
height: 100%;
overflow: hidden;
background-color: #009BE1;
}
h1.title {
display: inline-block;
font: bold 16px Arial, sans-serif;
margin: 0 5px 0 15px;
position: relative;
top: 25%;
}
.main {
width: 100%;
overflow: hidden;
position: absolute;
top: 48px;
bottom: 0;
}
/* left bar */
.left-bar {
width: 160px;
float: left;
padding:10px;
background-color: #F0F0F0;
height: 100%;
position: relative;
border-right:1px solid #aaa;
box-shadow:5px 0 5px #ccc;
}
.content {
overflow: hidden;
left: 12px;
padding: 5px 17px 5px 5px;
height: 100%;
position: relative;
}
Appreciated your help..
If you want the box shadow to appear inside of the element instead of outside, use inset. Then you want to invert the x-offset so it appears on the right side.
box-shadow:inset -5px 0 5px #ccc;
http://jsfiddle.net/5y1guk6d/3/