Radius does not adapt in navigationbar - html

I am working at a mobile bottom navigation bar. Here is the code I developed:
body {
background-color: #ff0000;
}
.mobile_bottombar {
display: flex;
align-items: center;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 60px;
padding: 0 12px;
background-color: #fff;
z-index: 999;
}
.des:before { /* creates the circle */
position: absolute;
content: url("data:image/svg+xml; utf8, <svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M24 10h-10v-10h-4v10h-10v4h10v10h4v-10h10z'/></svg>");
width: 66px;
height: 66px;
top: -45px;
left: calc(50% - 33px);
border-radius: 50%;
background-color: #188071;
justify-content: center;
align-items: center;
display: flex;
}
.des {
border-radius: 6px;
background: radial-gradient(40px 40px at 50% -11px, rgba(0, 0, 0, 0) 38.5px, #fff);
}
<div class="mobile_bottombar des">
<div class="bottombar_item" onclick="switchPage(2, 'main', true)">
<div>
<span>Sepp</span>
</div>
</div>
<div style="margin-right: 20px;" class="bottombar_item" onclick="switchPage(3, 'noteslist', true)">
<div>
<span>Depp</span>
</div>
</div>
<div style="margin-left: 20px;" class="bottombar_item">
<div>
<span>Mepp</span>
</div>
</div>
<div class="bottombar_item" onclick="switchPage(4, 'permission', true)">
<div>
<span>Repp</span>
</div>
</div>
</div>
My problem is that the radius which is cut of the div is another radius than the blue circle. Or maybe there is the other problem which I do not know? Anyway, that looks very weired, because of the different space around the circle. But how to fix that?
~marcelo

You can try #Temani's comment or if you want to stick to your method continue the reading.
I think that there is no relative way to do it so all you can do is hard-changing the value of the radial-gradient in the .des rule like this:
background: radial-gradient(40px 40px at 50% -11px, rgba(0, 0, 0, 0) 38.5px, #fff);
I also advice you to remove the box-shadowand replace it with
filter: drop-shadow(0px -2px 1px black);
instead, because we can see the shadow crossing the transparent area.

Related

Is this elmement layout possible in CSS? Overlapping shapes with transparency in a specific arrangement

I'm trying to replicate a design using CSS, a simplified example of this is below:
The pink background should be 50% opacity, however the blue offset shadow/border should be 100% opacity.
I can do the general shapes but not in a way to achieve the desired transparency.
Here is an attempt I made:
.container {
position: relative;
margin: 0 auto;
width: 600px;
height: 200px;
}
.content-wrap {
position: relative;
z-index: 1;
filter: drop-shadow(13px 15px 0 rgb(0,255,255));
width: 60%;
height: 100%;
}
.content {
clip-path: polygon(0 0, 100% 0, 70% 100%, 0% 100%);
background: rgba(255,0,255, 0.5);
height: 200px;
}
.background {
z-index: 0;
position: absolute;
top: 20px;
left: 0;
background: black;
width: 500px;
height: 90px;
margin-top: 50px;
}
<div class="container">
<div class="content-wrap">
<!-- Blue -->
<div class="content">
<!-- Pink -->
</div>
</div>
<div class="background">
<!-- Black -->
</div>
</div>
A couple of aspects are not quite right:
The drop-shadow is visible through the pink, it should just be outside of the element.
The blue should extend to the left-hand edge.
The blue is transparent when I have not assigned it to be, it seems to be related to the child element's background being transparent.
Are there any CSS masters who can figure out a way to do this? The HTML can change if needed.
a box-shadow with skew transformation can do the job here. I am using pseudo-element for the sake of the demo but you can replace them with real elements
.box {
margin: 10px 0;
display: flex;
position: relative;
}
.box::before {
content: "";
position: absolute;
inset: 30% 0;
background: black;
}
.box::after {
content: "";
height: 200px;
width: 50%;
transform-origin: top;
transform: skew(-20deg);
background: rgb(255 0 255/80%);
box-shadow: 25px 25px 0 blue;
}
body {
margin: 0
}
<div class="box">
</div>

I want to have an image align left with the text in the <h1> tags below but am trouble finding a solution

I need to have a second image align left of the text but layered on top of the background image. I am having some trouble figuring out what css I need to make this work. Currently everything I have tried messes with the text positioning or the background image.
Luckily, this is a personal project so there is no timeline but I would appreciate any help that could be given.
I just started learning web development this past year so it all still feels a little new to me.
.hero-full-container {
height: 100vh;
position: relative
}
.background-image-container {
background-size: cover;
background-repeat: no-repeat;
background-position: 50%
}
.white-text-container h1 {
color: #fff
}
.overlay-gradient {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, .3), transparent);
background-image: -o-linear-gradient(top, rgba(0, 0, 0, .3) 0, transparent 100%);
background-image: linear-gradient(180deg, rgba(0, 0, 0, .3) 0, transparent);
background-repeat: repeat-x;
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#4D000000", endColorstr="#00000000", GradientType=0)
}
.container {
margin-right: auto;
margin-left: auto;
padding-left: 15px;
padding-right: 15px
}
.row {
margin-left: -15px;
margin-right: -15px
}
.col-xs-12 {
position: relative;
min-height: 1px;
padding-left: 15px;
padding-right: 15px
}
.col-md-7 {
width: 58.33333%
}
.col-md-offset-1 {
margin-left: 8.33333%
}
.hero-full-wrapper .text-content {
padding-top: 30%
}
<div class="hero-full-container background-image-container white-text-container" style="background-image:url('./assets/images/home_01.jpg')">
<div class="overlay-gradient"></div>
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-7 col-md-offset-1">
<div class="hero-full-wrapper">
<div class="text-content">
<h1>William</h1>
<h1>Mark</h1>
<h1>Derichsweiler</h1>
<!--<p>Lorem ipsum</p>-->
</div>
</div>
</div>
</div>
</div>
</div>
I don't undestand very well your question, but if you want to have a background image and another image above this image, you can do this creating more div. Once you insert a background image, you can insert another div inside this div, e.g. :
<div class="main-container">
<div class="second-image">
<img src="link_to_your_image">
</div>
<div class="text-area">
<h1>William</h1>
<h1>Mark</h1>
<h1>Derichsweiler</h1>
</div>
</div>
and the for css, you can use flex property, setting the direction to flex-direction: row, e.g. :
*{
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
.main-container {
width: 100%;
height: 100%;
background-image: url('link_to_your_image');
background-color: red;
display: flex;
flex-direction: row;
align-items: center;
}
.second-image, .text-area {
margin-left: 50px;
}
I hope this can help you, have a nice day.

How does work position sticky relative window?

Lets suppose we have window with horizontal scroll.
There is another block on the page. If set it position: relative and set top: 20px does it mean that 20px from top of window in visible area or including scroll?
Here is demo of your question. Not sure if this answers your question, feel free to edit.
https://jsfiddle.net/joshmoto/zbc12ayu/1/
#import "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css";
.scroll-x {
overflow-x: scroll;
height: 400px;
border: 2px dotted #e83e8c;
}
.top-block {
position: relative;
top: 20px;
height: 40px;
background: rgba(0,0,0,0.75);
color: #ffffff;
line-height: 40px;
text-align: center;
}
.scolling-content {
background-image: linear-gradient(to right, orange, yellow, green, cyan, blue, violet);
width: 2560px;
height: 400px;
}
<div class="container mt-3">
<h4 class="mt-3 mb-3">Scroll Horizontal</h4>
<div class="scroll-x">
<div class="top-block"><code>position: relative; top: 20px;</code></div>
<div class="scolling-content"></div>
</div>
</div>

border curved css - circle with curved end

I am building a website, and I'm having a hard time doing a detail in CSS
I need to make a round border that has a curved end, for you to understand better, I will show photo and post my code
What I need (Photoshop)
I would like a CSS solution, but I could not.
Here is what I have actually:
.bottom-bar {
background: #29a7e8;
position: absolute;
bottom: 0;
width: 100%;
height: 50px;
text-align: center;
}
.circle {
display: inline-block;
position: relative;
top: -10px;
border-radius: 100%;
background: #29a7e8;
width: 60px;
height: 60px;
margin: 0 1rem;
}
<div class="bottom-bar">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
You can do this using SVG as background:
.bottom-bar {
background: #29a7e8;
position: absolute;
bottom: 0;
width: 100%;
height: 50px;
text-align: center;
}
.circle {
display: inline-block;
position: relative;
top: -28px;
border-radius: 100%;
background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='10 10 45 15' width='64' height='64' fill='%2329a7e8'><path d='M12 24 L52 24 L52 16 C40 16 42 10 32 10 C20 10 22 16 12 16 Z' /></svg>") 0 0/100% 100% no-repeat;
width: 60px;
height: 60px;
margin: 0 1rem;
}
<div class="bottom-bar">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
<svg xmlns='http://www.w3.org/2000/svg'
viewBox='10 10 45 15'
width='64' height='64'
fill='#29a7e8'>
<path d='M12 24 L52 24 L52 16 C40 16 42 10 32 10 C20 10 22 16 12 16 Z' />
</svg>
For a CSS only solution you can consider a combination of radial-gradient to create the curve:
.bottom-bar {
background: #29a7e8;
position: absolute;
bottom: 0;
width: 100%;
height: 50px;
text-align: center;
}
.circle {
display: inline-block;
position: relative;
top: -30px;
background:
radial-gradient(circle at top right,transparent 50%,#29a7e8 51%)100% 21px/12px 10px no-repeat,
radial-gradient(circle at top left,transparent 50%,#29a7e8 51%)0 21px/12px 10px no-repeat,
radial-gradient(circle at center,#29a7e8 55%, transparent 56%);
width: 60px;
height: 60px;
margin: 0 1rem;
}
<div class="bottom-bar">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
In general, there are for ways to create that kind of shapes, from simple to more complex:
Adding 2 pseudoelements with radial-gradient.
Simplest and well-supported solution. Probably the one I would use.
Adding 2 pseudoelements with mask-image (same as above, but with worse support).
Quite similar, code-wise, to the previews one, but with really bad support (needs browser prefixes for those that support it).
If you want to check how similar they are, take a look at this other similar question: CSS "inverse border-radius" outside element's bounding box to create a mobile phone notch design
Adding 2 pseudoelements with a border-radius, box-shadow and background: transparent.
Needs a bit more code, but it looks a bit smoother, at least on Chrome Version 78.0.3904.108, although the difference is minimal. In any case, the shapes you can do can't be as complex as with the previous alternatives, especially if you want to work with ellipses rather than circles, as it is your case.
Using an SVG.
I think the SVG solution is not worth it here, but it would be a good alternative for more complex shapes or animated/transitioning shapes. In any case, Temani Afif already added a solution using SVG.
Something to keep in mind is that, as that looks like a navigation bar, the hoverable/clickable area of each button should match as good as possible what users actually see, which is not the case for Temani Afif's solutions.
This is what it would look like using radial-gradient:
body {
margin: 0;
font-family: monospace;
background: #DDD;
}
.bar {
background: white;
position: fixed;
bottom: 0;
width: 100%;
height: 60px;
text-align: center;
}
.circle {
position: relative;
top: -10px;
border-radius: 100%;
background: white;
width: 60px;
height: 60px;
margin: 0 16px;
cursor: pointer;
display: inline-flex;
justify-content: center;
align-items: center;
font-size: 24px;
font-weight: bold;
color: black;
transition: box-shadow ease-in 150ms;
background: white;
border: 0;
outline: none;
}
.circle:hover {
box-shadow: 0 16px 16px 0 rgba(0, 0, 0, .125);
}
.circle:active {
box-shadow: 0 8px 8px 0 rgba(0, 0, 0, .125);
}
.circle::before,
.circle::after {
content: "";
position: absolute;
top: 4px;
width: 32px;
height: 6px;
background: white;
z-index: 1;
}
.circle::before {
left: -18px;
background: radial-gradient(ellipse at 0% -25%, transparent 0, transparent 70%, white 70%, white 100%);
}
.circle::after {
right: -18px;
background: radial-gradient(ellipse at 100% -25%, transparent 0, transparent 70%, white 70%, white 100%);
}
<nav class="bar">
<button class="circle">💖</button>
<button class="circle">🚀</button>
<button class="circle">🌍</button>
</nav>
If you want to see a similar question and all the alternatives in action, check this out: CSS "inverse border-radius" outside element's bounding box to create a mobile phone notch design

CSS shadow for :before and :after on a scrollable container

I have a container which is scrollable. I would like to add an inset shadow at the beginning of the container and another one in the opposite direction at the bottom of the container. Attached is an image of what I have vs what I'm trying to achieve.
This is the shadow I'm trying to attach at the top, and a reversed one at the bottom. Notice that the left and right side fade just a bit.
CSS for shadow:
.list {
height: 100px;
overflow: auto;
position: relative;
}
.list:before {
content: "";
position: absolute;
width: 100%;
margin: 0 auto;
height: 12px;
border: 0;
box-shadow: inset 0 12px 12px -12px rgba(0,0,0,0.5);
}
.list:after {
content: "";
position: absolute;
width: 100%;
margin: 0 auto;
height: 12px;
border: 0;
box-shadow: inset 0 -12px 12px -12px rgba(0,0,0,0.5);
bottom: 0;
}
I have these two issues:
When I scroll, the shadows move, how can I keep them in place?
I tried fixed position, but then they are not limited to the container.
How can I achieve a slight fade on the shadow at the left and right?
I tried transform: rotateX(1deg) rotateY(0deg) rotateZ(0deg) with perspective: 10px but no real results - but I think this is a starting point.
A plunker with this code in it:
http://plnkr.co/edit/YREOxLXUfN7xCUQDwc77?p=preview
You'll need to add a container <div> to achieve this. Something like this:
.list-container {
height: 100px;
position: relative;
}
.list-container:before {
display:block;
content: "";
position: absolute;
width: 100%;
margin: 0 auto;
height: 12px;
border: 0;
box-shadow: inset 0 12px 12px -12px rgba(0,0,0,0.5);
}
.list-container:after {
display:block;
content: "";
position: absolute;
width: 100%;
margin: 0 auto;
height: 12px;
border: 0;
box-shadow: inset 0 -12px 12px -12px rgba(0,0,0,0.5);
bottom: 0;
}
.list {
height: 100px;
overflow: auto;
}
<div class="list-container">
<div class="list">
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
<div> {{item}} </div>
</div>
</div>
As for the slight fade you desire, have a look here: Taper/fade CSS box shadow?
Well, about the scrolling issue, the solution is in the video from Lea Verou conference.
I could post the code here, but people should see the video, it deserves it
About the request shadow, generated with backgrounds, I porvide you 2 different options, generated with multiple backgrounds. The first uses rounded corners, the second linear ones.
I have done it bigger and darker than requested, so that the difference is easier to see.
.one {
width: 200px;
height: 150px;
border: solid 1px red;
background-image: radial-gradient(circle at bottom right, black 0%, white 70%),
radial-gradient(circle at bottom left, black 0%, white 70%),
linear-gradient(to top, black 0%, white 100%);
background-size: 40px 40px, 40px 40px, 100% 40px;
background-repeat: no-repeat;
background-position: bottom left, bottom right, bottom left;
}
.two {
width: 200px;
height: 150px;
left: 220px; top: 10px;
position: absolute;
border: solid 1px red;
background-image: linear-gradient(-45deg, black 0%, white 50%),
linear-gradient(45deg, black 0%, white 50%),
linear-gradient(to top, black 0%, white 100%);
background-size: 40px 40px, 40px 40px, 100% 40px;
background-repeat: no-repeat;
background-position: bottom left, bottom right, bottom left;
}
<div class="one"></div>
<div class="two"></div>
something like this?
.wrapList:before {
content: "";
position: fixed;
width: 100%;
margin: 0 auto;
height: 12px;
background: linear-gradient(90deg, rgba(0,0,0,0.2), rgba(0,0,0,.5));
overflow: hidden;
box-shadow: inset 0 12px 12px -12px rgba(0,0,0,0.5);
}
.wrapList:after {
content: "";
position: absolute;
width: 100%;
margin: 0 auto;
height: 12px;
border: 0;
box-shadow: inset 0 -12px 12px -12px rgba(0,0,0,0.3);
background: linear-gradient(90deg, rgba(0,0,0,.3), rgba(0,0,0,0.2));
}
with
<div class="wrapList">
<div class="list">
<div ng-repeat="item in items"> {{item}} </div>
</div>
</div>