How to make a bottom arrow hole in a rectangle [duplicate] - css

This question already has answers here:
Transparent arrow/triangle indented over an image
(4 answers)
Closed 2 years ago.
I want to change the button on my website.
like this.
But I don't know how to change the bottom style of this button.
I heard we can do this using '::after' or '::before'.

Something like this is one of the 100 options
.my-special-thing {
position: relative;
padding: 20px 30px;
background-color: orange;
display: inline-block;
}
.my-special-thing:before {
position: absolute;
right: 30px;
bottom: -10px;
width: 20px;
height: 20px;
content: '';
display: block;
background-color: white;
transform: rotate(45deg);
}
<div class="my-special-thing">Post a job</div>

Yes , this can be achieved using before & after , please check the code below
.Box {
width: 200px;
height: 50px;
background-color: #F7E6D2;
display:flex;
justify-content: center;
align-items:center;
}
.Box::before {
bottom: 0;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(0, 0, 0, 0);
border-bottom-color: #F4F4F5;
border-width: 11px;
margin-left: -11px;
}
.Box::after{
bottom: 0;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #ffffff;
border-width: 10px;
margin-left: -10px;
}
<section id="Items">
<div class="Box">
<h3>Case</h3>
</div>
</section>

Related

Slanted box shadow on left and right side

I am trying to make slanted box shadow on both sides of a div, which I have added here as an image.
The red part is indicating here shadow. actually color is not solid, it should gradually decrease when it is moving to outside from border.
Here is my contribution hope it gives you a baseline.
.box {
width: 150px;
height: 200px;
position: relative;
padding-left: 25px;
padding-right: 25px;
}
.box-content {
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
background-color: white;
border: 2px solid black;
width: 100%;
height: 100%;
position: relative;
}
.box::before {
content: '';
display: block;
border-top: 0;
border-bottom: 180px solid transparent;
border-right: 25px solid red;
position: absolute;
left: 0;
bottom: 0;
}
.box::after {
content: '';
display: block;
border-top: 0;
border-bottom: 180px solid transparent;
border-left: 25px solid red;
position: absolute;
right: -4px;
bottom: 0;
}
<div class="box">
<div class="box-content">
Box
</div>
</div>
Try this:
div{
width: 200px;
height: 200px;
border:1px solid black;
background: white;
}
div:before{
content:' ';
display:block;
width: 200px;
height:200px;
background: linear-gradient(transparent, black);
position: fixed;
transform: matrix3d(1.1,0,0.00,0,0.00,0.71,0.71,0.0007,0,-0.71,0.71,0,0,37,0,1); z-index: -1;
}
<div>Hello</div>
Using transform: skew() applied to the div's before and after
jsFiddle 1
code:
#test {
width: 150px;
height: 220px;
line-height: 220px;
background-color: white;
border: 2px black solid;
text-align: center;
position: relative;
margin: 10px 150px;
}
#test:before, #test:after {
width: 150px;
height: 200px;
position: absolute;
bottom: 0;
left: -11px;
z-index: -1;
content: " ";
display: block;
background-color: red;
transform: skew(5deg, 0);
}
#test:after {
transform: skew(-5deg, 0);
left: 11px;
}
<div id="test">Box</div>
EDIT : to give the shadow effect some real blur with gradient and transparency, we could make use of linear-gradient background with two rgba() values, as well as CSS blur() (1) filter.
jsFiddle 2
code:
#test {
width: 150px;
height: 220px;
line-height: 220px;
background-color: white;
border: 2px black solid;
text-align: center;
position: relative;
margin: 10px 150px;
}
#test:before, #test:after {
width: 150px;
height: 200px;
position: absolute;
bottom: 0;
left: -11px;
z-index: -1;
content: " ";
display: block;
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.7));
transform: skew(5deg, 0);
filter: blur(2px);
}
#test:after {
transform: skew(-5deg, 0);
left: 11px;
}
<div id="test">Box</div>
Notes:
(1) browser support for CSS filter

Custom css for border-bottom

I had applied css to this thing but is there any way where i can do css of this type ?
means decreasing the bottom of the border line?
See if this help.
p {
position: relative;
z-index: 1;
width: 30px;
background: red;
padding: 10px;
color: #fff;
}
p:before {
content: "";
position: absolute;
left: 5px;
bottom: 0;
width: 80%;
border-bottom: 4px solid black;
height: 1px;
}
<p>
hello
</p>

How to make arrows on both sides of a box using css [duplicate]

This question already has answers here:
How do CSS triangles work?
(23 answers)
Closed 7 years ago.
I want to make a rectangle with arrows on both sides.
I have the jsfiddle http://jsfiddle.net/7wegxh4v/ .
Here is my css
<body>
<div id="arrowbox"></div>
</body>
#arrowbox
{
width: 200px;
height: 50px;
background-color:green;
margin-left:100px;
margin-top:100px;
}
It now shows a green rectangle. I want to add two equilateral triangle triangles of green color at both ends. How can I do that using css? Any idea?
Try this (using Pseudo-elements):
CSS
#arrowbox
{
width: 200px;
height: 50px;
background-color:green;
margin-left:100px;
margin-top:100px;
position: relative;
}
#arrowbox:after {
left: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(0, 128, 0, 0);
border-left-color: #008000;
border-width: 25px;
margin-top: -25px;
}
#arrowbox:before {
right: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(0, 128, 0, 0);
border-right-color: #008000;
border-width: 25px;
margin-top: -25px;
}
DEMO HERE

Make Ribbon Appear Behind Rectangle

I am trying to create a ribbon at the beginning of a rectangle. However, I cannot figure out how to make it appear BEHIND the rectangle.
Please see this codepen: http://codepen.io/gosusheep/pen/aOqOBy
The part for creating the ribbon and putting it behind the rectangle is here:
.rectangle::before{
content: "";
width: 0;
height: 0;
display: block;
position: absolute;
z-index: -1;
border-left: 25px solid transparent;
border-right: 25px solid $blue;
border-top: 25px solid $blue;
border-bottom: 25px solid $blue;
left: -30px;
top: 10%;
}
Even with position: absolute, and z-index: -1, it appears ON TOP of the div.
Can anyone help with this?
What is happening here is that apparently, the property transform: translateX(-50%); it's "overriding" in some way the z-index. My solution is just center rectangle otherwise, for example:
.rectangle{
margin: 0 auto;
}
DEMO
The reason for your problem is not because children cannot be positioned behind their parent but because you are using a transform on the parent. Using transforms affect the stacking context like mentioned in this answer by BoltClock.
One solution would be to avoid the transform totally and use left: calc(50% - 100px) instead to position the ribbon at the center (like in the below snippet). (50% - 100px) is used as the value because 100px is half of the box width (50% is the center point of the parent).
.rectangle {
width: 200px;
height: 50px;
background-color: #8080ff;
position: relative;
left: calc(50% - 100px); /* newly added */
border: 1px #6666ff solid;
}
ul {
list-style: none;
}
li {
display: inline;
}
li + li::before {
content: " | ";
}
.container {
width: 100%;
position: relative;
}
.rectangle {
width: 200px;
height: 50px;
background-color: #8080ff;
position: relative;
left: calc(50% - 100px); /* newly added */
border: 1px #6666ff solid;
}
.rectangle::before {
content: "";
width: 0;
height: 0;
display: block;
position: absolute;
z-index: -1;
border-left: 25px solid transparent;
border-right: 25px solid #8080ff;
border-top: 25px solid #8080ff;
border-bottom: 25px solid #8080ff;
left: -30px;
top: 10%;
}
<p>put a pipe between nav elements</p>
<nav>
<ul>
<li>banana</li>
<li>woof</li>
<li>quack</li>
</ul>
</nav>
<p>Ribbon on the end of a rectangle</p>
<div class='container'>
<div class='rectangle'></div>
</div>
If in case you can't use the above solution, then you could follow the approach described below.
Assuming you don't have any other use for the ::after pseudo-element, you could use that to create the rectangle and give it a z-index higher than the ::before pseudo-element to make it appear behind the rectangle.
/* Modified */
.rectangle {
width: 200px;
height: 50px;
position: relative;
left: 50%;
transform: translateX(-50%);
}
/* Added */
.rectangle::after {
content: "";
width: 100%;
height: 100%;
top: 0px;
left: 0px;
display: block;
position: absolute;
background-color: #8080ff;
border: 1px #6666ff solid;
z-index: -1;
}
.rectangle{
padding: 4px;
box-sizing: border-box;
}
Below is a sample snippet:
ul {
list-style: none;
}
li {
display: inline;
}
li + li::before {
content: " | ";
}
.container {
width: 100%;
position: relative;
}
.rectangle::before {
content: "";
width: 0;
height: 0;
display: block;
position: absolute;
z-index: -2;
border-left: 25px solid transparent;
border-right: 25px solid #8080ff;
border-top: 25px solid #8080ff;
border-bottom: 25px solid #8080ff;
left: -30px;
top: 10%;
}
/* Modified */
.rectangle {
width: 200px;
height: 50px;
position: relative;
left: 50%;
transform: translateX(-50%);
}
/* Added */
.rectangle::after {
content: "";
width: 100%;
height: 100%;
top: 0px;
left: 0px;
display: block;
position: absolute;
background-color: #8080ff;
border: 1px #6666ff solid;
z-index: -1;
}
.rectangle{
padding: 4px;
box-sizing: border-box;
}
<p>put a pipe between nav elements</p>
<nav>
<ul>
<li>banana</li>
<li>woof</li>
<li>quack</li>
</ul>
</nav>
<p>Ribbon on the end of a rectangle</p>
<div class='container'>
<div class='rectangle'>
Some content
</div>
</div>
Solution here, look closely at z-indexes and positions
.container{
position: relative;
width: 100%;
z-index: 1;
}
.rectangle{
width: 200px;
height: 50px;
background-color: $blue;
position: absolute;
left: 50%;
border: 1px darken($blue,5%) solid;
}
.rectangle::after{
content: "";
width: 0;
height: 0;
border-left: 25px solid transparent;
border-right: 25px solid $blue;
border-top: 25px solid $blue;
border-bottom: 25px solid $blue;
left: -30px;
top: 10px;
position: absolute;
z-index: -1;
}
And your codepen edited http://codepen.io/anon/pen/mJXeed working now

How to customize ionic style components (lists and tabs with different shapes)

I was trying to customize ionic lists and tabs but since I am not too experienced in css does anyone know how to get these layouts ? :
List picture:
TABS picture:
You could use a border trick with some pseudo elements for this:
.onecorner,
.twocorners {
height: 50px;
width: 300px;
line-height: 50px;
text-align: center;
background: lightgray;
margin-left: 25px;
margin-right: 25px;
position: relative;
}
.onecorner:after{
content: "";
position: absolute;
top: 0;
left: 100%;
height:100%;
width:25px;
background:inherit;
}
.onecorner:before,
.twocorners:before {
content: "";
position: absolute;
top: 0;
left: 0;
transform: translateX(-100%);
width: 0;
height: 25px;
border-top: 25px solid transparent;
border-right: 25px solid lightgray;
}
.twocorners:after {
content: "";
position: absolute;
top: 0;
right: 0;
transform: translateX(100%);
width: 0;
height: 25px;
border-bottom: 25px solid transparent;
border-left: 25px solid lightgray;
}
<div class="onecorner">tab 1</div>
<br/>
<div class="twocorners">tab 2</div>

Resources