My problem is my div that is called .border, the only purpose of it is to make cool border effect around the 2 headlines in the middle-left of the landingp age picture. But you can see pretty good in the screenshot, that the .border is kind of attached to the picture and stretches out. I have really no clue how to make this border perfectly centered behind the text.
.home {
margin: 3rem 6rem 3rem 6rem;
background-image: url(img/Aliens\ Cows.jpg);
background-repeat: no-repeat;
background-size: inherit;
min-height: 20rem;
box-shadow: .5rem .5rem .5rem rgba(0, 0, 0, 0.2), 1rem 1rem 0rem var(--clr-main);
}
.layer-over-p {
min-height: 20rem;
z-index: 1;
background: linear-gradient(90deg, rgba(32, 31, 27, 0.5), rgb(255, 234, 0, 0.6));
backdrop-filter: blur(6px);
}
.text-1 {
text-shadow: 0.5rem 0.5rem 0.4rem rgba(0, 0, 0, 0.2);
margin-top: 4.5rem;
margin-left: 8rem;
}
.text-1 a {
font-size: 6rem;
text-decoration: none;
color: #fff;
text-transform: uppercase;
font-family: var(--ff-primary);
}
.text-2 {
text-shadow: 0.3rem 0.3rem 0.4rem rgba(0, 0, 0, 0.2);
margin-top: -1.6rem;
margin-left: 8.32rem;
}
.text-2 a {
font-size: 1.6rem;
text-decoration: none;
color: rgb(189, 189, 189);
text-transform: uppercase;
font-family: var(--ff-primary);
}
.border {
position: absolute;
z-index: 2;
}
/* ANIMATIONS = Navbar + Home *******************************************/
.border {
border-top: 3px solid transparent;
border-right: 3px solid transparent;
border-bottom: 3px solid transparent;
border-left: 3px solid transparent;
transition: border-top 0.5s ease-in-out, border-right 0.5s ease-in-out, border-bottom 0.5s ease-in-out, border-left 0.5s ease-in-out;
}
.border:hover {
border-top: 3px solid var(--clr-accent);
border-right: 3px solid var(--clr-accent);
border-bottom: 3px solid var(--clr-accent);
border-left: 3px solid var(--clr-accent);
}
<section class="home">
<div class="border">
<div class="text-1">My Work</div>
<div class="text-2">See my Creations.</div>
</div>
<div class="layer-over-p"></div>
</section>
I moved your background CSS from layer-over-p into border and wrapped both your text elements in a div with some arbitrary amount of padding. I also added #Antoine Richard's answer of simplifying the border CSS to get this result:
.home {
margin: 3rem 6rem 3rem 6rem;
background-image: url(img/Aliens\ Cows.jpg);
background-repeat: no-repeat;
background-size: inherit;
min-height: 20rem;
box-shadow: .5rem .5rem .5rem rgba(0, 0, 0, 0.2), 1rem 1rem 0rem var(--clr-main);
}
.layer-over-p {
min-height: 20rem;
z-index: 1;
}
.text-1 {
text-shadow: 0.5rem 0.5rem 0.4rem rgba(0, 0, 0, 0.2);
}
.text-1 a {
font-size: 6rem;
text-decoration: none;
color: #fff;
text-transform: uppercase;
font-family: var(--ff-primary);
}
.text-2 {
text-shadow: 0.3rem 0.3rem 0.4rem rgba(0, 0, 0, 0.2);
margin-top: -1.6rem;
margin-left: 8.32rem;
}
.text-2 a {
font-size: 1.6rem;
text-decoration: none;
color: rgb(189, 189, 189);
text-transform: uppercase;
font-family: var(--ff-primary);
}
.border {
position: absolute;
background: linear-gradient(90deg, rgba(32, 31, 27, 0.5), rgb(255, 234, 0, 0.6));
backdrop-filter: blur(6px);
z-index: 2;
overflow: wrap;
}
/* ANIMATIONS = Navbar + Home *******************************************/
.border {
border: 3px solid transparent;
transition: border-color 0.5s ease-in-out;
}
.border:hover {
border-color: var(--clr-accent);
}
<section class="home">
<div class="border">
<div style = "padding: 65px">
<div class="text-1">My Work</div>
<div class="text-2">See my Creations.</div>
</div>
</div>
</section>
This appears to keep your text items centered both within your gradient background and border, if that is what you are looking for.
For those who have maybe the same problem, just fixed it by deleting the margin of the text and adding the margin to the border. The Border how I added it in my post was including the margin of the text. That's why the border had such a big size.
As border needs some space, you need to define it even if it's not visible.
To do that, define invisible border :
border: 3px solid transparent;
Then when you need to show it :
border-color: var(--clr-accent);
And for for transition :
transition: border-color 0.5s ease-in-out;
Also, you don't need to define it for each side as they all have the same value
Related
How to get this neumorphic styled input using CSS?
This is my code it's not sharp enough as in the image attached. Other than changing tweaking the box shadow is there anything else that can be added to this?
#import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css");
body {
background: #efefef;
}
input {
padding: 1.5em 5em;
background: #efefef;
border: none;
border-radius: 1.5rem;
color: #444;
font-size: 1rem;
font-weight: 700;
letter-spacing: .2rem;
text-align: center;
outline: none;
box-shadow: inset -6px -6px 14px rgba(255, 255, 255, .7), inset -6px -6px 10px rgba(255, 255, 255, .5), inset 6px 6px 8px rgba(255, 255, 255, .075), inset 6px 6px 10px rgba(0, 0, 0, .15);
}
.form-input {
font-size: 2rem;
position: relative;
}
.form-input .icon {
left: 0;
margin: .5em;
position: absolute;
top: 0;
}
<div class="form-input">
<label for="input4" class="icon glyphicon glyphicon-pencil"></label>
<input type='text' placeholder='Text' />
</div>
Try using this:
#import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css");
:root {
--primary-light: #8abdff;
--primary: #6d5dfc;
--primary-dark: #5b0eeb;
--white: #ffffff;
--greyLight-1: #e4ebf5;
--greyLight-2: #c8d0e7;
--greyLight-3: #bec8e4;
--greyDark: #9baacf;
}
body {
background: #efefef;
}
input {
width: 20.4rem;
height: 4rem;
border: none;
border-radius: 1rem;
font-size: 1.4rem;
padding-left: 4rem;
box-shadow: inset 0.2rem 0.2rem 0.5rem var(--greyLight-3), inset -0.2rem -0.2rem 0.5rem var(--white);
background: none;
font-family: inherit;
color: var(--greyDark);
}
input::-moz-placeholder {
color: var(--greyLight-3);
}
input:-ms-input-placeholder {
color: var(--greyLight-3);
}
input::placeholder {
color: var(--greyLight-3);
}
input:focus {
outline: none;
box-shadow: 0.3rem 0.3rem 0.6rem var(--greyLight-2), -0.2rem -0.2rem 0.5rem var(--white);
}
input:focus + .search__icon {
color: var(--primary);
}
.form-input {
font-size: 2rem;
position: relative;
}
.form-input .icon {
height: 2rem;
position: absolute;
font-size: 2rem;
padding: 0 1rem;
display: flex;
color: var(--greyDark);
transition: 0.3s ease;
top: 6px;
}
I used variables so you can make it according to your needs.
I am trying to make a button with a hover effect and ::after pseudo class is involved.
The ::after pseudo-class covers 100% of the button's height and width, even more just to be sure; then when :hover, the ::after element's width will shrink to 0.
My problem is that I can't precisely size the ::after element, so I simply added overflow: hidden; to the button so that it will cut out the overflowing parts of the ::after pseudo-element. But it cropped a little too much, leaving one pixel between the border and the ::after pseudo-element covering the button.
.btn {
font-family: inherit;
background-color: transparent;
text-decoration: none;
padding: 1rem 1.5rem;
font-size: 2.3rem;
color: #fff;
border: solid 3px #EF9C43;
width: 50%;
border-radius: 100rem;
text-transform: uppercase;
font-weight: 400;
transition: color 0.3s, transform 0.3s, box-shadow 0.3s;
position: relative;
box-shadow: 1rem 1rem 4rem rgba(31, 31, 31, 0.5);
z-index: 5;
backface-visibility: hidden;
overflow: hidden;
}
.btn::after {
content: "";
position: absolute;
top: -2px;
left: -2px;
background-color: #EF9C43;
width: 110%;
height: 110%;
z-index: -1;
transition: width 0.3s;
}
.btn:hover {
font-weight: 600;
color: #1f1f1f;
transform: translateY(-0.3rem);
box-shadow: 1rem 1.5rem 2rem rgba(31, 31, 31, 0.6);
}
.btn:active {
transform: translateY(-0.1rem);
box-shadow: 1rem 1.25rem 2.5rem rgba(31, 31, 31, 0.5);
}
.btn:hover::after {
width: 0;
}
<button class="btn btn--orange">Hire our services</button>
Here is the codepen of my case: https://codepen.io/CoolBoiDave/pen/bGLdwxE
Any help would be appreciated! (PS: sorry for bad english)
I don't know why would you use an ::after pseudo element when all you need is to
transition a background-image.
Also, you could use an inset box-shadow instead of border.
.btn {
background-color: transparent;
padding: 1rem 1.5rem;
font: 400 2.3rem sans-serif;
text-transform: uppercase;
color: #fff;
border: 0;
border-radius: 4rem;
font-weight: 400;
transition: color .3s, background-position .3s, box-shadow .3s;
box-shadow: 0 1rem 4rem rgba(0,0,0,0.3), inset 0 0 0 3px #EF9C43;
background-image: linear-gradient(90deg, rgba(255,145,0,1) 50%, rgba(0,0,0,0) 50%);
background-size: 200%;
}
.btn:hover,
.btn:active {
background-position: 100%;
color: #1f1f1f;
box-shadow: 0 1.5rem 2rem rgba(0,0,0,0.3), inset 0 0 0 3px #EF9C43;
}
<button class="btn btn--orange">Hire our services</button>
I'm trying to remove the ring around a material icon that I'm using as a close icon on a draggable element.
Here's a picture of the element (I've changed the background to red for you to highlight the problem), I want to remove the red outer circle so the nice border of the element goes all the way to the edge of the grey circle:
Here's the HTML and CSS for the element and the icon:
HTML:
<div class="print-element">
Tag Number
<mat-icon class="resize-circle">highlight_off</mat-icon>
</div>
CSS:
.print-element {
min-width: 175px;
min-height: 45px;
border: solid 1px #ccc;
color: rgba(0, 0, 0, 0.87);
display: inline-flex;
justify-content: center;
align-items: center;
text-align: center;
background: #fff;
border-radius: 4px;
margin-right: 25px 25px 15px 0px;
cursor: move;
position: relative;
z-index: 1;
box-sizing: border-box;
padding: 10px 50px 10px 10px;
transition: box-shadow 200ms cubic-bezier(0, 0, 0.2, 1);
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2),
0 2px 2px 0 rgba(0, 0, 0, 0.14),
0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.resize-circle{
position: absolute;
top: -10px;
right: -10px;
background-color: white;
border: .1px solid white;
border-radius: 50%;
color: #aaa;
cursor: pointer;
}
.mat-icon {
background-repeat: no-repeat;
display: inline-block;
fill: currentColor;
height: 24px;
width: 24px;
}
Now I can change the size of the mat-icon, but that results in the below:
using:
.mat-icon {
background-repeat: no-repeat;
display: inline-block;
fill: currentColor;
height: 20px;
width: 20px;
}
yields:
Here's a stackblitz all set up and ready to go: https://stackblitz.com/edit/angular-m7wwvr?file=src%2Fstyles.scss
Here's what I want it to look like:
Even pointers in the right direction would help.
Check edited URL for the changes in HTML and CSS
https://stackblitz.com/edit/angular-m7wwvr-xrmyje?file=src/styles.scss
Ok here is an answer. I used #Srinivas Bendkhale answer to reach this result.
what I did was wrapping the icon with a span and give it a fix hight and width then all I had to do was to hide the overflow .
That's how it looks in my browser.
.print-element {
min-width: 175px;
min-height: 45px;
border: solid 1px #ccc;
color: rgba(0, 0, 0, 0.87);
display: inline-flex;
justify-content: center;
align-items: center;
text-align: center;
background: #fff;
border-radius: 4px;
margin-right: 25px 25px 15px 0px;
cursor: move;
position: relative;
z-index: 1;
box-sizing: border-box;
padding: 10px 50px 10px 10px;
transition: box-shadow 200ms cubic-bezier(0, 0, 0.2, 1);
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.resize-circle {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
border: .1px solid white;
color: #aaa;
cursor: pointer;
}
span {
width: 20px;
height: 20px;
background: white;
position: absolute;
top: -7px;
border-radius: 50%;
right: -7px;
overflow: hidden;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="print-element">
Tag Number
<span><i class="material-icons resize-circle">highlight_off</i></span>
</div>
I have been trying to make a link fade effect in CSS. There are two divs inside a tag, the top one fades away on hover revealing the inner content.
However when the inside div has larger content it just overflows.I realize this is due to the position:absolute and so its width is ignored by the parent a.
Is there a way the parent a could take the biggest width of the two divs ?
My code here:
The first link works as expected because the inner div has lesser contentThe second link is the one describing this problem.
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0px;
padding: 0px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
text-align: center;
}
a,
a:hover,
a:focus,
a:active {
text-decoration: none;
outline: none;
color: #444;
}
a.fade {
border: 1px solid #ddd;
overflow: hidden;
display: inline-block;
}
a.fade > div {
display: inline-block;
padding: 10px 15px 10px 15px;
-moz-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
-webkit-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
text-align: center;
}
a.fade>div:first-child {
position: absolute;
}
a.fade > div:last-child {
z-index: 1;
position: relative;
background-color: #ffaaaa;
opacity: 1;
left: 0px;
top: 0px;
-moz-box-shadow: 1px 1px 3px 1px rgba(00, 0, 0, 0.2);
-webkit-box-shadow: 1px 1px 3px 1px rgba(00, 0, 0, 0.2);
box-shadow: 1px 1px 3px 1px rgba(00, 0, 0, 0.2);
}
a.fade:hover {
-moz-box-shadow: inset 0px 0px 3px 1px rgba(00, 0, 0, 0.2);
-webkit-box-shadow: inset 0px 0px 3px 1px rgba(00, 0, 0, 0.2);
box-shadow: inset 0px 0px 3px 1px rgba(00, 0, 0, 0.2);
}
a.fade:hover > div:last-child {
opacity: 0;
}
<a href="#" class="fade">
<div>Content inside</div>
<div>This one fades</div>
</a>
<a href="#" class="fade">
<div>Content inside</div>
<div>This fades</div>
</a>
Any kind of workaround in html structure is appreciated as well, as long as the final thing is achieved.
You will be able to achieve it using absolute positioning. But the same thing needs the parent to be relative one.
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0px;
padding: 0px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
text-align: center;
}
a,
a:hover,
a:focus,
a:active {
text-decoration: none;
outline: none;
color: #444;
}
a.fade {
border: 1px solid #ddd;
overflow: hidden;
display: inline-block;
position: relative;
}
a.fade > span {
display: inline-block;
padding: 10px 15px 10px 15px;
-moz-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
-webkit-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
text-align: center;
}
a.fade > span:first-child {
position: relative;
z-index: 1;
}
a.fade > span:last-child {
z-index: 1;
position: absolute;
background-color: #ffaaaa;
opacity: 1;
left: 0;
top: 0;
right: 0;
bottom: 0;
-moz-box-shadow: 1px 1px 3px 1px rgba(00, 0, 0, 0.2);
-webkit-box-shadow: 1px 1px 3px 1px rgba(00, 0, 0, 0.2);
box-shadow: 1px 1px 3px 1px rgba(00, 0, 0, 0.2);
}
a.fade:hover {
-moz-box-shadow: inset 0px 0px 3px 1px rgba(00, 0, 0, 0.2);
-webkit-box-shadow: inset 0px 0px 3px 1px rgba(00, 0, 0, 0.2);
box-shadow: inset 0px 0px 3px 1px rgba(00, 0, 0, 0.2);
}
a.fade:hover > span:last-child {
opacity: 0;
}
<a href="#" class="fade">
<span>Content inside</span>
<span>This one fades</span>
</a>
<a href="#" class="fade">
<span>Content inside</span>
<span>This fades</span>
</a>
Please note that you have to make a { display: block; /* or inline-block */ } for your HTML to stay valid. Otherwise a cannot contain block level elements.
Instead of absolute positioning, you can use a relative positioning and a negative bottom margin on the second div and set a background-color on the first, pulling the second div behind the first. Then you could transition opacity on the first div on hover. This will require setting a higher z-index on the second div than on the first.
a {
border: 20px solid blue;
display: inline-block;
color: #fff;
}
a :first-child {
background-color: #a00;
position: relative;
transition-duration: 0.2s;
z-index: 3;
}
a :last-child {
background-color: #0a0;
margin-bottom: -1.2em;
position: relative;
top: -1.2em;
z-index: 2;
}
a:hover :first-child {
opacity: 0;
}
<a href="#">
<div>Linktext</div>
<div>Longer Link text on hover</div>
</a>
This is what I currently have:
What I'm trying to do is remove the bottom box-shadow of the textarea (the one just above the B, I, and U) so that it ends up looking like this:
Here's the JSFiddle: http://jsfiddle.net/MgcDU/7616/
HTML:
<div class="editor span4">
<textarea class="span4"></textarea>
<ul class="format-post">
<li><b>B</b></li>
<li><i>I</i></li>
<li><u>U</u></li>
</ul>
</div>
CSS:
#import url('http://getbootstrap.com/2.3.2/assets/css/bootstrap.css');
body {
margin: 10px;
}
textarea {
border-radius: 2px 2px 0 0;
border-bottom-color: #eee;
}
textarea:focus {
border-bottom-color: #eeeeee;
}
textarea:focus + .format-post {
border-color: rgba(82, 168, 236, 0.8);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 7px rgba(82, 168, 236, 0.6);
transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
}
.format-post {
list-style: none;
background: #fafafa;
height: 35px;
border: 1px solid #cccccc;
border-top: 0;
border-radius: 0 0 2px 2px;
margin: 0;
margin-top: -10px;
}
.format-post li {
width: 35px;
height: 35px;
border-right: 1px solid #eee;
text-align: center;
line-height: 33px;
font-size: 14px;
color: #333;
cursor: pointer;
display: inline-block;
}
Please help.
I just changed the box-shadow to
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
0 -4px 7px rgba(82, 168, 236, 0.6);
and it worked! :)
The bottom color was still blue, so I just changed it to
border-bottom: 1px solid #999;
You can change it if needed! :)
Here is the fiddle: http://jsfiddle.net/afzaal_ahmad_zeeshan/MgcDU/7617/
Pardon me, I just saw that you want the textarea to be colored, which doesn't fit for the question. You're saying in title to remove the border-bottom. But in answer you're having bottom border for both.
If you want to get the border and all animation when textarea is not active, then remove :focus and it will do the job.
And I am still very sorry, for unclear answer because I am not able to get it, which should be answered the question or the answer.