I want to design the above image using pure CSS.
Following is the HTML and CSS I have come up with so far:
<div>
<input
className="my_file"
type="file"
onChange={(event) => {
setImageSelected(event.target.files[0]);
}}
/>
<svg
width="20"
height="18"
viewBox="0 0 20 18"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="upload_image_icon"
>
<path
d="M7 0L5.17 2H2C0.9 2 0 2.9 0 4V16C0 17.1 0.9 18 2 18H18C19.1 18 20 17.1 20 16V4C20 2.9 19.1 2 18 2H14.83L13 0H7ZM10 15C7.24 15 5 12.76 5 10C5 7.24 7.24 5 10 5C12.76 5 15 7.24 15 10C15 12.76 12.76 15 10 15Z"
fill="white"
/>
</svg>
<Avatar
src={picture}
alt="Avatar"
id="hello"
className="avatar--profile_image"
/>
</div>
and here is my scss:
.profile--card_container {
width: 348px;
height: 448px;
// border: 1px solid rgb(211, 211, 211);
// border-radius: 5px;
.avatar--profile_image {
justify-content: center !important;
margin-bottom: 10px;
margin-top: 10px;
margin-left: 6.50rem;
height: 100px !important;
width: 100px !important;
box-shadow: rgba(0, 0, 0, 0.01) 0px 5px 16px 0px,
rgba(0, 0, 0, 0.10) 0px 0px 0px 0px;
position: relative;
overflow: hidden;
background-size: cover;
background-position: center;
background-blend-mode: multiply;
color: transparent;
transition: all .3s ease;
cursor: pointer;
border: 2px solid rgba(0, 0, 0, 0.54);
&:after {
content:'\A';
position:absolute;
width:100%; height:100%;
top:0; left:0;
background:rgba(0,0,0,0.6);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
&:hover:after {
opacity:1;
}
}
input[type=file]::-webkit-file-upload-button {
cursor: pointer;
}
.my_file {
position: absolute;
outline: none;
color: transparent;
box-sizing: border-box;
transition: 0.5s;
margin: 45px 0 0 100px;
z-index: 1;
opacity: 0;
cursor: pointer;
}
.upload_image_icon {
margin: 44px 0 0 144px;
cursor: pointer;
position: absolute;
outline: none;
box-sizing: border-box;
z-index: 1;
}
}
here is how my result look like for now:
I am trying to achieve like when I hover profile picture the image will overlay black color and appear camera icon. How can I do that ?
Wrap the image within a div. and then use a pesudo-element with a z-index that onyl dispalys when you hover that div like in the snippet below:
.avatar {
width: 100px;
height: 100px;
position: relative;
}
.avatar img {
width: 100%;
object-fit: cover;
border-radius: 50%;
}
.avatar > div {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.6);
z-index: 2;
display: none;
}
.avatar:hover > div {
display: flex;
justify-content: center;
align-items: center;
}
<div class="avatar">
<img src="https://via.placeholder.com/500x500.jpg">
<div>Icon</div>
</div>
Related
I have a simple settings menu and I want to position the toggle open and close button at the right position:
So far I'm here:
.base {
position: absolute;
max-width: 30em;
background-color: #fff;
padding: 1.125em 1.5em;
font-size: 1.25em;
border-radius: 1rem;
box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.3), 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.2);
}
.base::before {
content: "";
position: absolute;
width: 0;
height: 0;
bottom: 100%;
right: 1.5em;
border: 0.75rem solid transparent;
border-top: none;
border-bottom-color: #fff;
filter: drop-shadow(0 -0.0625rem 0.0625rem rgba(0, 0, 0, 0.1));
}
html {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 300;
color: #192229;
background: linear-gradient(135deg, #F4F2F3, #BFC6D0);
}
html, body {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
body {
padding: 0 2rem;
}
label {
font-family: "Montserrat", sans-serif;
font-size: 1.2rem;
cursor: pointer;
display: block;
margin: 1em;
}
label > input {
display: none;
}
label span {
color: #6A759B;
}
label i {
display: inline-block;
width: 64px;
height: 40px;
border-radius: 20px;
vertical-align: middle;
transition: 0.25s 0.09s;
position: relative;
background: #deeff7;
}
label i:after {
content: " ";
display: block;
width: 30px;
height: 30px;
top: 5px;
left: 5px;
border-radius: 50%;
background: #fff;
position: absolute;
box-shadow: 1px 2px 4px 0 rgba(0, 0, 0, 0.4);
transition: 0.15s;
}
label > input:checked + i {
background: #1094fb;
}
label > input:checked + i + span {
color: #29316b;
}
label > input:checked + i:after {
transform: translateX(25px);
}
.filter {
position: absolute;
}
.burger {
display: flex;
flex-direction: column;
filter: url(#gooeyness);
padding: 30px;
}
.rect {
background: black;
display: inline-block;
height: 32px;
margin-top: 40px;
transition: transform 500ms;
width: 200px;
}
.rect:nth-child(2) {
transition-delay: 100ms;
}
.rect:nth-child(3) {
transition-delay: 100ms;
}
.burger.active .rect:nth-child(1) {
transform: rotate(-45deg) translateX(-51px) translateY(50px);
}
.burger.active .rect:nth-child(2) {
transform: rotate(45deg);
}
.burger.active .rect:nth-child(3) {
transform: rotate(-45deg) translateX(51px) translateY(-50px);
}
.close {
position: absolute;
cursor: pointer;
transform: scale(0.1);
z-index: 2500;
}
.settings-container {
display: flex;
flex-direction: column;
width: 500px;
justify-content: center;
height: 250px;
align-items: center;
}
<div class="settings-container">
<div class="close">
<svg class="filter" version="1.1">
<defs>
<filter id="gooeyness">
<feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10" result="gooeyness" />
<feComposite in="SourceGraphic" in2="gooeyness" operator="atop" />
</filter>
</defs>
</svg>
<div class="burger">
<div class="rect"></div>
<div class="rect"></div>
<div class="rect"></div>
</div>
</div>
<div class="base">
<label>
<input class="cb cb1" type="checkbox" name="social" checked/>
<i></i>
<span>آموزش کارت حتی در صورت پاسخ صحیح</span>
</label>
<label>
<input class="cb cb1" type="checkbox" name="social" checked/>
<i></i>
<span>ضبط صدا در صورت استفاده از تشخیص گفتار</span>
</label>
<label>
<input class="cb cb1" type="checkbox" name="social" checked/>
<i></i>
<span>نمایش جلوه های ویژه ی صوتی و بصری</span>
</label>
</div>
</div>
The issue is I don't know how to position the toggle button at the right place! here is where I want it to be:
Notice that here on SO you can not see the button here is a codepen for it:
https://codepen.io/pixy-dixy/pen/OJjJygg?editors=1100
So the fist issue is that your code produces an different to the one you show in your screenshot. The hamburger menu is in a different place as shown in the image below.
But your problem really stems from a few issues in your css. You can see the step by step below or just jump to the full css at the end. The first is to get it to do what your screen shot is showing you need to do this. Please not I have just uncommented out the code so you can see the changes
.close {
/*position: absolute;*/
cursor: pointer;
transform: scale(0.1);
z-index: 2500;
}
.settings-container {
/*display: flex;
flex-direction: column;*/
width: 500px;
justify-content: center;
/*height: 250px;*/
align-items: center;
}
this now produces the below
Then for reference purposes I have added a border to your settings-container to illustrate what is happening.
The code that cause this is the transform: scale(0.1) shown below and commented out.
.close {
/*position: absolute;*/
cursor: pointer;
/*transform: scale(0.1);*/
z-index: 2500;
}
This now produces this result.
Now you can change the burger menu rectangles to the correct size rather than using transform.
.rect {
background: black;
display: inline-block;
height: 5px;
margin-top: 5px;
transition: transform 500ms;
width: 30px;
}
.close {
/*position: absolute;*/
cursor: pointer;
/*transform: scale(0.1);*/
z-index: 2500;
}
This produces the below result
now you can just position the hamburger menu to right.
.close {
display: flex;
justify-content:end;
/*position: absolute;*/
cursor: pointer;
/*transform: scale(0.1);*/
z-index: 2500;
}
it will look like this
final touches add margin (red border is removed as it was only for illustrative purposes). Your filter was also causing layout issues so I have commented it out.
.burger {
margin-bottom: 20px;
margin-right: 35px;
display: flex;
flex-direction: column;
filter: url(#gooeyness);
/*padding: 30px;*/
}
full css with commented our code
.base {
position: absolute;
max-width: 30em;
background-color: #fff;
padding: 1.125em 1.5em;
font-size: 1.25em;
border-radius: 1rem;
box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.3), 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.2);
}
.base::before {
content: "";
position: absolute;
width: 0;
height: 0;
bottom: 100%;
right: 1.5em;
border: 0.75rem solid transparent;
border-top: none;
border-bottom-color: #fff;
filter: drop-shadow(0 -0.0625rem 0.0625rem rgba(0, 0, 0, 0.1));
}
html {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 300;
color: #192229;
background: linear-gradient(135deg, #F4F2F3, #BFC6D0);
}
html, body {
height: 100%;
display: flex;
justify-content: center;
/*align-items: center;*/
}
body {
padding: 0 2rem;
}
label {
font-family: "Montserrat", sans-serif;
font-size: 1.2rem;
cursor: pointer;
display: block;
margin: 1em;
}
label > input {
display: none;
}
label span {
color: #6A759B;
}
label i {
display: inline-block;
width: 64px;
height: 40px;
border-radius: 20px;
vertical-align: middle;
transition: 0.25s 0.09s;
position: relative;
background: #deeff7;
}
label i:after {
content: " ";
display: block;
width: 30px;
height: 30px;
top: 5px;
left: 5px;
border-radius: 50%;
background: #fff;
position: absolute;
box-shadow: 1px 2px 4px 0 rgba(0, 0, 0, 0.4);
transition: 0.15s;
}
label > input:checked + i {
background: #1094fb;
}
label > input:checked + i + span {
color: #29316b;
}
label > input:checked + i:after {
transform: translateX(25px);
}
.filter {
position: absolute;
}
.burger {
margin-bottom: 20px;
margin-right: 35px;
display: flex;
flex-direction: column;
filter: url(#gooeyness);
/*padding: 30px;*/
}
.rect {
background: black;
display: inline-block;
height: 5px;
margin-top: 5px;
transition: transform 500ms;
width: 30px;
}
.rect:nth-child(2) {
transition-delay: 100ms;
}
.rect:nth-child(3) {
transition-delay: 100ms;
}
.burger.active .rect:nth-child(1) {
transform: rotate(-45deg) translateX(-6px) translateY(6px);
}
.burger.active .rect:nth-child(2) {
transform: rotate(45deg);
}
.burger.active .rect:nth-child(3) {
transform: rotate(-45deg) translateX(6px) translateY(-8px);
}
.close {
display: flex;
justify-content:end;
/*position: absolute;*/
cursor: pointer;
/*transform: scale(0.1);*/
z-index: 2500;
}
.border{
border:1px solid red;
}
.settings-container {
/*display: flex;
flex-direction: column;*/
width: 500px;
/*justify-content: center;
height: 250px;
align-items: center;*/
}
MDN
CSS positioning is used here to place the element in the desired spot.
Notice that I added position: relative to .settings-container and position: absolute to .close.
The addition of position: relative is used because...
It (the absolutely positioned element) is positioned relative to its closest positioned ancestor, if any;
otherwise, it is placed relative to the initial containing block.
Then the element you are positioning gets position: absolute which will place the element relative to .settings-container which is now the "closest positioned ancestor".
.base {
position: relative;
max-width: 30em;
background-color: #fff;
padding: 1.125em 1.5em;
font-size: 1.25em;
border-radius: 1rem;
box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.3), 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.2);
}
.base::before {
content: "";
position: absolute;
width: 0;
height: 0;
bottom: 100%;
right: 1.5em;
border: 0.75rem solid transparent;
border-top: none;
border-bottom-color: #fff;
filter: drop-shadow(0 -0.0625rem 0.0625rem rgba(0, 0, 0, 0.1));
}
html {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 300;
color: #192229;
background: linear-gradient(135deg, #F4F2F3, #BFC6D0);
}
html,
body {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
body {
padding: 0 2rem;
}
label {
font-family: "Montserrat", sans-serif;
font-size: 1.2rem;
cursor: pointer;
display: block;
margin: 1em;
}
label>input {
display: none;
}
label span {
color: #6A759B;
}
label i {
display: inline-block;
width: 64px;
height: 40px;
border-radius: 20px;
vertical-align: middle;
transition: 0.25s 0.09s;
position: relative;
background: #deeff7;
}
label i:after {
content: " ";
display: block;
width: 30px;
height: 30px;
top: 5px;
left: 5px;
border-radius: 50%;
background: #fff;
position: absolute;
box-shadow: 1px 2px 4px 0 rgba(0, 0, 0, 0.4);
transition: 0.15s;
}
label>input:checked+i {
background: #1094fb;
}
label>input:checked+i+span {
color: #29316b;
}
label>input:checked+i:after {
transform: translateX(25px);
}
.filter {
position: absolute;
}
.burger {
display: flex;
flex-direction: column;
filter: url(#gooeyness);
padding: 30px;
}
.rect {
background: black;
display: inline-block;
height: 32px;
margin-top: 40px;
transition: transform 500ms;
width: 200px;
}
.rect:nth-child(2) {
transition-delay: 100ms;
}
.rect:nth-child(3) {
transition-delay: 100ms;
}
.burger.active .rect:nth-child(1) {
transform: rotate(-45deg) translateX(-51px) translateY(50px);
}
.burger.active .rect:nth-child(2) {
transform: rotate(45deg);
}
.burger.active .rect:nth-child(3) {
transform: rotate(-45deg) translateX(51px) translateY(-50px);
}
.close {
cursor: pointer;
transform: scale(0.1);
position: absolute; /* added */
top: -170px; /* added */
right: -88px; /* added */
}
.settings-container {
display: flex;
flex-direction: column;
position: relative; /* added */
}
<div class="settings-container">
<div class="close">
<svg class="filter" version="1.1">
<defs>
<filter id="gooeyness">
<feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10" result="gooeyness" />
<feComposite in="SourceGraphic" in2="gooeyness" operator="atop" />
</filter>
</defs>
</svg>
<div class="burger">
<div class="rect"></div>
<div class="rect"></div>
<div class="rect"></div>
</div>
</div>
<div class="base">
<label>
<input class="cb cb1" type="checkbox" name="social" checked/>
<i></i>
<span>آموزش کارت حتی در صورت پاسخ صحیح</span>
</label>
<label>
<input class="cb cb1" type="checkbox" name="social" checked/>
<i></i>
<span>ضبط صدا در صورت استفاده از تشخیص گفتار</span>
</label>
<label>
<input class="cb cb1" type="checkbox" name="social" checked/>
<i></i>
<span>نمایش جلوه های ویژه ی صوتی و بصری</span>
</label>
</div>
</div>
move it using the position tag in CSS
https://www.w3schools.com/css/css_positioning.asp
Just add position relative to settings-container so the children of this container will count space Regarding to its boundries and then try this.
.base {
position: absolute;
top: 10px: // Change 10px according to your requirement.
right: 10px: // Change 10px according to your requirement.
max-width: 30em;
background-color: #fff;
padding: 1.125em 1.5em;
font-size: 1.25em;
border-radius: 1rem;
box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.3), 0 0.0625rem 0.125rem
rgba(0, 0, 0, 0.2);
}
I would like to custom my profile pic like in this picture but I can't, don't know what's wrong.
I have an external bootstrap CSS file though. What I want to follow the Facebook profile pice update design but facing small issue, I have attached a pic to see how I want it
HTML
<div class="user-thumb user-thumb--edit">
<div class="custom-file">
<input class="custom-file__input" id="photo" accept="image/*" type="file">
<label class="custom-file__label" for="photo">
<img alt="" class="thumb--lg rounded-circle" src="">
</label>
</div>
</div>
Here is the CSS
.user-thumb {
position: relative;
display: inline-block;
background: #e9e9e9;
border-radius: 50%;
}
.user-thumb--edit {
position: relative;
margin-bottom: 1rem;
}
.custom-file {
margin: 0;
height: auto;
}
.custom-file__input {
position: absolute;
opacity: 0;
visibility: hidden;
width: 1px;
height: 1px;
}
.custom-file__label {
cursor: pointer;
border: 0;
text-align: center;
font-weight: 500;
font-size: 1rem;
display: block;
margin: 0;
border-radius: 0;
padding: 0;
background: transparent;
position: relative;
}
.user-thumb--edit .custom-file__label::before {
content: '';
position: absolute;
bottom: 0;
right: 0;
text-align: center;
transition: all 0.15s ease-in-out;
z-index: 20;
background: #ffffff url();
background: 1.4rem auto;
width: 4.2rem;
height: 4.2rem;
border-radius: 100%;
box-shadow: 0px 6px 6px -3px rgb(0 0 0 / 20%), 0px 10px 14px 1px rgb(0 0 0 / 14%), 0px 4px 18px 3px rgb(0 0 0 / 12%);
}
You can achieve this if you set the border-radius of the label to 50% instead of 0 and add overflow: hidden, which would also hide a part of the ::before. Therefor you should define that ::before not for the label but for the containing div: .custom-file::before.
Working example:
.user-thumb {
position: relative;
display: inline-block;
background: #e9e9e9;
border-radius: 50%;
}
.user-thumb--edit {
position: relative;
margin-bottom: 1rem;
}
.custom-file {
margin: 0;
height: auto;
}
.custom-file__input {
position: absolute;
opacity: 0;
visibility: hidden;
width: 1px;
height: 1px;
}
.custom-file__label {
cursor: pointer;
border: 0;
text-align: center;
font-weight: 500;
font-size: 1rem;
display: block;
margin: 0;
border-radius: 50%;
padding: 0;
background: transparent;
position: relative;
overflow: hidden;
}
.user-thumb--edit .custom-file::before {
content: '';
position: absolute;
bottom: 0;
right: 0;
text-align: center;
transition: all 0.15s ease-in-out;
z-index: 20;
background: #ffffff url();
background: 1.4rem auto;
width: 4.2rem;
height: 4.2rem;
border-radius: 100%;
box-shadow: 0px 6px 6px -3px rgb(0 0 0 / 20%), 0px 10px 14px 1px rgb(0 0 0 / 14%), 0px 4px 18px 3px rgb(0 0 0 / 12%);
}
<div class="user-thumb user-thumb--edit">
<div class="custom-file">
<input class="custom-file__input" id="photo" accept="image/*" type="file">
<label class="custom-file__label" for="photo">
<img alt="" class="thumb--lg rounded-circle" src="https://via.placeholder.com/150">
</label>
</div>
</div>
Based on a few examples here and there I made one o those search elements in which there's only the icon visible and the text field slides to the right when hovering either the icon or its parent element:
#import URL( 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css' );
:root {
--darker-gray: 22, 22, 22; /** #191919 */
--mid-gray: 89, 89, 89; /** #595959 */
}
header .top {
background-color: rgba( var( --darker-gray ) );
-webkit-box-shadow: 0 3px 5px -2px #0D0D0D;
box-shadow: 0 3px 5px -2px #0D0D0D;
color: rgba( var( --light-text ) );
padding: 2.5rem;
position: fixed;
top: 0;
width: 100%;
}
.wrapper input {
background: transparent;
border: none;
color: rgba( var( --mid-gray ) );
cursor: pointer;
display: inline-block;
font-size: 2rem;
height: 3.75rem;
left: 2.5rem;
outline: none;
position: absolute;
top: 0;
transition: all .5s;
width: 0;
z-index: 3;
}
.wrapper svg {
cursor: pointer;
margin-top: -1.5rem;
position: relative;
top: -1px;
}
.wrapper:hover input,
.wrapper:focus input,
.wrapper:focus-within input {
border-bottom: 1px solid rgba( var( --mid-gray ) );
cursor: text;
width: 24rem;
z-index: 1;
}
.wrapper:hover svg,
.wrapper:focus svg,
.wrapper:focus-within svg {
left: 22rem;
}
.icon.search {
fill: rgba(var(--mid-gray));
height: 2.25rem;
width: 2.25rem;
}
<header>
<div class="top">
<div class="d-flex justify-content-between">
<div class="wrapper">
<input placeholder="search" type="text" />
<svg class="icon search button">
<path d="M9.516 14.016q1.875 0 3.188-1.313t1.313-3.188-1.313-3.188-3.188-1.313-3.188 1.313-1.313 3.188 1.313 3.188 3.188 1.313zM15.516 14.016l4.969 4.969-1.5 1.5-4.969-4.969v-0.797l-0.281-0.281q-1.781 1.547-4.219 1.547-2.719 0-4.617-1.875t-1.898-4.594 1.898-4.617 4.617-1.898 4.594 1.898 1.875 4.617q0 0.984-0.469 2.227t-1.078 1.992l0.281 0.281h0.797z"/>
</svg>
</div>
</div>
</div>
</header>
There's some misalignment on the icon but, for some reason, it's just here
Worked nicely but it was too blunt. So I've added a transition transition: all .5s; and it worked perfectly... on the opening. When the text field gets hidden, the grey line goes first, then the placeholder text and finally the SVG icon.
Also, after I've added the transition, on page load the text box flickers for a moment. After a few tests I've found out the culprit is the all defined in the transition tule that's, as expected, is also affecting the background-color required to make the text field transparent.
How could I make it smoother, showing/hiding everything at the same time without this flickering?
if you also add a transition on SVG and its left coordonates, does it look better to you ?
Also, transition can be set only on a single or more properties alike :
transition: width .5s, z-index 0.5s; to occur only on width and z-index.
#import URL( 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css' );
:root {
--darker-gray: 22, 22, 22; /** #191919 */
--mid-gray: 89, 89, 89; /** #595959 */
}
header .top {
background-color: rgba( var( --darker-gray ) );
-webkit-box-shadow: 0 3px 5px -2px #0D0D0D;
box-shadow: 0 3px 5px -2px #0D0D0D;
color: rgba( var( --light-text ) );
padding: 2.5rem;
position: fixed;
top: 0;
width: 100%;
}
.wrapper input {
background: transparent;
border: none;
color: rgba( var( --mid-gray ) );
cursor: pointer;
display: inline-block;
font-size: 2rem;
height: 3.75rem;
left: 2.5rem;
outline: none;
position: absolute;
top: 0;
transition: width .5s, z-index 0.5s;
width: 0;
z-index: 3;
}
.wrapper svg {
cursor: pointer;
margin-top: -1.5rem;
position: relative;
top: -1px;
left:0;
transition:left .5s;
}
.wrapper:hover input,
.wrapper:focus input,
.wrapper:focus-within input {
border-bottom: 1px solid rgba( var( --mid-gray ) );
cursor: text;
width: 24rem;
z-index: 1;
}
.wrapper:hover svg,
.wrapper:focus svg,
.wrapper:focus-within svg {
left: 22rem;
}
.icon.search {
fill: rgba(var(--mid-gray));
height: 2.25rem;
width: 2.25rem;
}
<header>
<div class="top">
<div class="d-flex justify-content-between">
<div class="wrapper">
<input placeholder="search" type="text" />
<svg class="icon search button">
<path d="M9.516 14.016q1.875 0 3.188-1.313t1.313-3.188-1.313-3.188-3.188-1.313-3.188 1.313-1.313 3.188 1.313 3.188 3.188 1.313zM15.516 14.016l4.969 4.969-1.5 1.5-4.969-4.969v-0.797l-0.281-0.281q-1.781 1.547-4.219 1.547-2.719 0-4.617-1.875t-1.898-4.594 1.898-4.617 4.617-1.898 4.594 1.898 1.875 4.617q0 0.984-0.469 2.227t-1.078 1.992l0.281 0.281h0.797z"/>
</svg>
</div>
</div>
</div>
</header>
The text wont display on-top of the video.
I am basically wanting a title which i called Heading to display overlaid on the video. I have tried fiddling with z-index and it does not change, i did notice when I replace the video for an image the text worked, that was using different css code, I am assuming their is a problem with the css.
Please help me, THANK YOU.
CSS CODE:
.home-subheading {
font-family: 'Montserrat',sans-serif;
font-size: 14px;
letter-spacing: .5px;
font-weight: 400;
color: #ccc;
z-index:999!important;
}
.tp-banner .home-subheading {
line-height: 40px!important;
#home-revolution-slider {
width: 100%;
height: 100%;
min-height: 100%;
z-index: -99;
}
.hero {
position: fixed;
z-index: -99;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-size: cover;
}
.content {
position: relative;
z-index: 3;
background-color: #fff;
}
.home-heading,
.home-subheading,
.home-button {
position: absolute;
z-index: 999;
text-align: center;
transform: translateY(0px);
/*-webkit-transition: 1s opacity ease-in-out;*/
}
.tp-loader.spinner1 {
width: 40px;
height: 40px;
background: url(../img/assets/rev-loader.gif) no-repeat center center;
background-color: transparent;
box-shadow: none;
-webkit-box-shadow: none;
margin-top: -20px;
margin-left: -20px;
-webkit-animation: none;
animation: none;
border-radius: 0;
-moz-border-radius: 0;
-webkit-border-radius: 0;
}
.tp-banner-container{
width:100%;
position:relative;
padding:0;
margin-top: 0;
z-index: -1;
}
.tparrows.preview4:after {
background: #fff;
background: rgba(255,255,255,.05);
}
.tp-caption a {
color: #fff;
padding: 9px 22px;
box-shadow: 0 -3px rgba(0, 0, 0, 0.3) inset;
-moz-box-shadow: 0 -3px rgba(0, 0, 0, 0.3) inset;
-webkit-box-shadow: 0 -3px rgba(0, 0, 0, 0.3) inset;
-o-box-shadow: 0 -3px rgba(0, 0, 0, 0.3) inset;
margin: 0 7px 0 7px;
text-transform: uppercase;
}
.tp-caption a:hover {
color: #fff;
}
.html5-video-container video {
width: 100%!important;
height: auto!important;
left: 0!important;
z-index: -99;
}
.tp-banner-video video{
min-width: 100%;
z-index: -3;
HTML CODE:
<!-- MAIN IMAGE -->
<video src="img/coding.mp4" autoplay loop alt="video_typing_cover" data-bgposition="center center" data-bgfit="cover" data-bgrepeat="repeat"></video>
<!-- LAYERS -->
<!-- Home Heading -->
<div class="tp-caption sft"
data-x="center"
data-y="260"
data-speed="1200"
data-start="1100"
data-easing="Power3.easeInOut"
data-splitin="none"
data-splitout="none"
data-endspeed="300"
style="z-index: 4; max-width: auto; max-height: auto; white-space:normal;">
<h2 class="home-heading op-1">Digital Hive</h2>
</div>
<!-- LAYER NR. 1 -->
<div class="tp-caption tp-fade fadeout fullscreenvideo"
data-x="0"
data-y="0"
data-speed="1000"
data-start="1100"
data-easing="Power4.easeOut"
data-elementdelay="0.01"
data-endelementdelay="0.1"
data-endspeed="1500"
data-endeasing="Power4.easeIn"
data-autoplay="true"
data-autoplayonlyfirsttime="false"
data-nextslideatend="true"
data-volume="mute"
data-forceCover="1"
data-aspectratio="16:9"
data-forcerewind="on"
style="z-index: 2;">
<video class="img-responsive" preload="none"
poster='example'>
<source src='img/coding.mp4' autoplay type='video/mp4' />
</video>
</div>
I have tried adding a shadow to my triangle but it just wont work, this is so annoying!
Heres my code:
function section_about() {
$(".about").css("display", "inline-block");
$(".about").animate({opacity:"1"}, {duration: 1000, queue: false});
window.location.hash = "/About Us/";
}
function triangle_sizer() {
$(".triangle-up").css("border-left-width", jQuery(window).width()/2);
$(".triangle-up").css("border-right-width", jQuery(window).width()/2);
$(".triangle-up").css("top", jQuery(window).height()-125);
$(".triangle-down").css("border-left-width", jQuery(window).width()/2);
$(".triangle-down").css("border-right-width", jQuery(window).width()/2);
$(".triangle-down").css("top", jQuery(window).height()-125);
}
triangle_sizer();
jQuery(window).resize(function() {
triangle_sizer();
});
##style.css##
.triangle-down {
width: 0;
height: 0;
border-style: solid;
border-width: 100px 200px 0 100px;
border-color: rgba(39, 39, 39, 1) transparent transparent transparent;
box-shadow: 0 16px 10px -17px rgba(0, 0, 0, 0.5);
}
.triangle-down:after {
content: "";
position: absolute;
width: 0;
height: 0;
background: rgba(39, 39, 39, 1);
-webkit-transform: rotate(45deg);
box-shadow: -1px -1px 10px -2px rgba(0, 0, 0, 0.5);
}
.par {
position: absolute;
top: 200%;
width: 100%;
height: 0%;
}
/* Arrows */
.arrows {
width: 220px;
height: 144px;
position: absolute;
left: 50%;
top: 70%;
margin-left: -76.5px;
}
.arrows path {
stroke: white;
fill: transparent;
stroke-width: 1px;
}
/* Arrows */
.arrows-down {
width: 220px;
height: 144px;
position: absolute;
left: 50%;
top: 70%;
margin-left: -78.5px;
}
.arrows-down path {
stroke: white;
fill: transparent;
stroke-width: 1px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="par">
<div class="triangle-down">
<svg class="arrows-down" viewbox="0 0 102 102">
<path class="a1" d="M0 20 L30 52 L60 20"></path>
</svg>
</div>
</div>
I have been searching for a solution for a long time and cant find one. This is what happens when that code is ran:
https://gyazo.com/c890a79c547f5624c97abacc66104fc1
https://jsfiddle.net/Lec8862y/2/
HTML
<span class="triangle">▼</span>
CSS
span {
display: inline-block;
transform: scaleX(8.5);
color: lightgreen;
text-shadow:
0 2px 2px rgba(255,255,255,0.7),
0 10px 4px rgba(0,0,0,0.5);
font-size: 92px;
}
span:hover {
transition: all 0.2s ease;
transform: scaleX(9.5) translateY(4px);
text-shadow:
0 1px 1px rgba(0,0,0,0.5);
}
body {
padding: 20px;
margin-left: 260px;
margin-top: -40px
}
Working Fiddle: https://jsfiddle.net/rittamdebnath/drefg8r4/
You can try using box-shadow to build a triangle instead of border. Then on :before or :after elements you can set an overlapping box-shadow, example by Chris Coyier:
http://codepen.io/chriscoyier/pen/bNZWzK
You can cuplicate your element, align it directly behind the default triangle and use the css filter propertie in conjunction with absolute position and the back element size.
.triangle-down {
position: relative;
width: 220px;
height: 220px;
box-sizing: border-box;
}
.arrows-down {
display: block;
height: auto;
max-width: 200px;
box-sizing: border-box;
}
.arrows-down-back {
position: absolute;
left: 0;
top: 0;
max-width: 200px;
filter: blur(20px) opacity(.3);
-webkit-filter: blur(20px) opacity(.3);
}
<div class="par">
<div class="triangle-down">
<svg class="arrows-down img-responsive" viewbox="0 0 102 102">
<path class="a1" d="M0 20 L30 52 L60 20"></path>
</svg>
<svg class="arrows-down img-responsive arrows-down-back" viewbox="0 0 102 102">
<path class="a1" d="M0 20 L30 52 L60 20"></path>
</svg>
</div>
</div>
You could relay only on a gradient to draw and blur(shadow) the triangle.
If you use vertical margin/padding in percentage, it takes the width for reference, so arrow is resized from width, not height of content.
div {
position:relative;
color:white;
background:#333;
text-align:center;
margin:1em;
margin-bottom:5.5%;
box-shadow: 0 0 5px #333;
}
div:after {
content:'';
display:block;
position:absolute;
top:100%;
left:0;
right:0;
padding-top:5%;
background:linear-gradient(to bottom left, #333 49%, transparent 51%) no-repeat 0 0, linear-gradient(to bottom right, #333 49%, transparent 51%) no-repeat top right;
background-size:50% 99%
}
html {/* demo purpose to show arrow box is translucide */
background:linear-gradient(45deg, yellow,gray,purple,white,lime, yellow,gray,purple,white,lime);
min-height:100%;
}
<div>responsive box arrow, resize me or add content </div>
<div>i can be replicated <hr/> maybe you should use a <code>class</code> there </div>