How to position the button properly - html

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);
}

Related

How to make search bar responsive?

I want to make my html/css search bar responsive for example iphone 11.
Search button drops down after hovering over it, when i open it from my phone.
Here's the link: https://irinachikviladze.github.io/
How can I make it responsive using CSS?
<div class="search-box">
<input class="search-txt" type="text" name="" placeholder="Type to search">
<a class="search-btn" href="#">
<i class="fa-solid fa-magnifying-glass"></i>
</a>
</div>
Every HTML element has a default display value depending on what type of element it is. The default display value for most elements is block or inline.
So just overwrite the default display for your search box and set it to flex with flex-direction: row;
that's it.
body{
margin: 0;
padding: 0;
background:#e74c3c;
}
.search-box{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #34495e;
height: 40px;
border-radius: 40px;
padding: 10px;
display: flex;
flex-direction: row;
}
.search-box:hover > .search-txt{
width: 240px;
padding: 0 6px;
}
.search-box:hover > .search-btn{
background : white ;
}
.search-btn{
color: #e74c3c;
float: right;
width: 40px;
height: 40px;
border-radius: 50%;
background:#34495e;
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
overflow: hidden;
}
.search-txt{
border:none;
background: none;
outline: none;
float: left;
padding: 0;
color: white;
font-size: 16px;
transition: 0.4s;
line-height: 40px;
width: 0px;
}
/* responsive*/
#media only screen and (max-width: 828px){
.search-box:hover > .search-txt{
width: 125px;
}
}
<body>
<div class="search-box">
<input class="search-txt" type="text" name="" placeholder="Type to search">
<a class="search-btn" href="#">
<i class="fa-solid fa-magnifying-glass"></i>
</a>
</div>
</body>
Html element
<div class="Card">
<div class="CardInner">
<label>Search for your stack :)</label>
<div class="container">
<div class="Icon">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#657789" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
</div>
<div class="InputContainer">
<input placeholder="search here...."/>
</div>
</div>
</div>
</div>
CSS Element
#import url('https://fonts.googleapis.com/css?family=Orbitron&display=swap');
#import url('https://fonts.googleapis.com/css?family=Hind&display=swap');
* {
-webkit-font-smoothing: antialiased;
color: #acbdce;
}
:root {
--border-radius: 10px;
}
body, html {
background: #e2e9f4;
display: grid;
height: 100%;
grid-template: 1fr/100%;
place-items: center;
}
.Card {
padding: 1px;
border-radius: var(--border-radius);
background: linear-gradient(-67deg, rgba(#c8d8e7, .7), rgba(255,255,255,.8));
overflow: hidden;
box-shadow:
-2px -2px 6px rgba(#fff, .6),
2px 2px 12px #c8d8e7;
width: 380px;
}
.CardInner {
padding: 16px 16px;
background-color: #e2e9f4;
border-radius: var(--border-radius);
}
.container {
display: flex;
}
.Icon {
min-width: 46px;
min-height: 46px;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--border-radius);
margin-right: 12px;
box-shadow:
-2px -2px 6px rgba(#fff, .6),
2px 2px 12px #c8d8e7;
svg {
transform: translate(-1px, -1px);
}
}
label {
font-family: "Hind", sans-serif;
display: block;
color: #3c4b66;
margin-bottom: 12px;
background: linear-gradient(45deg, rgba(#6b7b8f, 1), #3c4b66);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.InputContainer {
width: 100%;
}
input {
background-color: #e3edf7;
padding: 16px 32px;
border: none;
display: block;
font-family: 'Orbitron', sans-serif;
font-weight: 600;
color: #a9b8c9;
-webkit-appearance: none;
transition: all 240ms ease-out;
width: 100%;
&::placeholder {
color: #6d7f8f;
}
&:focus {
outline: none;
color: #6d7f8f;
background-color: lighten(#e3edf7, 3%);
}
};
.InputContainer {
--top-shadow: inset 1px 1px 3px #c5d4e3, inset 2px 2px 6px #c5d4e3;
--bottom-shadow: inset -2px -2px 4px rgba(255,255,255, .7);
position: relative;
border-radius: var(--border-radius);
overflow: hidden;
&:before,
&:after {
left: 0;
top: 0;
display: block;
content: "";
pointer-events: none;
width: 100%;
height: 100%;
position: absolute;
}
&:before {
box-shadow: var(--bottom-shadow);
}
&:after {
box-shadow: var(--top-shadow);
}
}

Styling Navigation bar with logo and button

I have been trying for hours to style my navigation bar(which is horizontal at the top of the screen) so that my logo will show at left , menu on the center and the username with the logout button at right(all of them horizontally).I tried float ,position display, but nothing seems to work as i want.Instead the result is all the elements(logo,menu,username,logout button) to appear in the center.Any help would be appreciated.
HTML code
<header>
<div class="page">
<nav class="page__menu page__custom-settings menu">
<div class="logo">
<img src="images/logo.png">
</div>
<ul class="menu__list r-list">
<li class="menu__group">Main</li>
<li class="menu__group">Songs</li>
<li class="menu__group">Ratings</li>
</ul>
<section id="login">
Logout
<h1>User: <?php echo $user_data['user_name']; ?></h1>
</section>
</nav>
</header>
CSS code
.r-link{
display: var(--rLinkDisplay, inline-flex) !important;
}
.r-link[href]{
color: var(--rLinkColor) !important;
text-decoration: var(--rLinkTextDecoration, none) !important;
}
.r-list{
padding-right: var(--rListPaddingRight, 0) !important;
margin-top: var(--rListMarginTop, 0) !important;
margin-bottom: var(--rListMarginBottom, 0) !important;
margin-left: var(--rListMarginLeft, 0) !important;
list-style: var(--rListListStyle, none) !important;
}
.menu{
--rLinkColor: var(--menuLinkColor, currentColor);
display: flex;
justify-content: center;
}
.menu__link{
display: var(--menuLinkDisplay, block);
}
.menu__link:focus{
outline: var(--menuLinkOutlineWidth, 2px) solid var(--menuLinkOutlineColor, currentColor);
outline-offset: var(--menuLinkOutlineOffset);
}
.menu__link:hover{
--rLinkColor: #e8491d; ;
}
.menu{
background-color: var(--menuBackgroundColor, #f0f0f0);
box-shadow: var(--menuBoxShadow, 0 1px 3px 0 rgba(0, 0, 0, .12), 0 1px 2px 0 rgba(0, 0, 0, .24));
}
.menu__list{
display : flex;
}
.page__menu img{
float: left;
position: relative;
margin: 10px 15px 15px 10px;
display: block;
width: 450px;
max-width:100% ;
height: auto;
margin: auto;
}
.menu__link{
padding: var(--menuLinkPadding, 1.5rem 2.5rem);
font-weight: 700;
text-transform: uppercase;
}
.text-underlined{
position: relative;
overflow: hidden;
will-change: color;
transition: color .25s ease-out;
}
.text-underlined::before,
.text-underlined::after{
content: "";
width: 0;
height: 3px;
background-color: var(--textUnderlinedLineColor, currentColor);
will-change: width;
transition: width .1s ease-out;
position: absolute;
bottom: 0;
}
.text-underlined::before{
left: 50%;
transform: translateX(-50%);
}
.text-underlined::after{
right: 50%;
transform: translateX(50%);
}
.text-underlined:hover::before,
.text-underlined:hover::after{
width: 100%;
transition-duration: .2s;
}
.page__custom-settings{
--menuBackgroundColor: #255785;
--menuLinkColor: #fff;
--menuLinkColorUnactive: #241c69;
--menuLinkOutlineOffset: -.5rem;
}
.button {
background-color: #e8491d;
color: white;
padding: 10px 12px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 7px 7px;
transition-duration: 0.4s;
cursor: pointer;
float : right;
}
.button:hover {
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19);
}
h1 {
text-align: right;
font-size: 14px;
font-weight: bold;
font-family: "Times New Roman", Times, serif;
color: white;
padding: 20px;
}
Here is the result what I fixed, please check and let me know.
You need to change justify-content: space-between instead center to the menu and add align-items: center and align-items: center to the #login.
Added the fixed css code.
Hope it is helpful~
.r-link {
display: var(--rLinkDisplay, inline-flex) !important;
}
.r-link[href] {
color: var(--rLinkColor) !important;
text-decoration: var(--rLinkTextDecoration, none) !important;
}
.r-list {
padding-right: var(--rListPaddingRight, 0) !important;
margin-top: var(--rListMarginTop, 0) !important;
margin-bottom: var(--rListMarginBottom, 0) !important;
margin-left: var(--rListMarginLeft, 0) !important;
list-style: var(--rListListStyle, none) !important;
}
.menu {
--rLinkColor: var(--menuLinkColor, currentColor);
display: flex;
justify-content: space-between;
align-items: center;
}
.menu__link {
display: var(--menuLinkDisplay, block);
}
.menu__link:focus {
outline: var(--menuLinkOutlineWidth, 2px) solid var(--menuLinkOutlineColor, currentColor);
outline-offset: var(--menuLinkOutlineOffset);
}
.menu__link:hover {
--rLinkColor: #e8491d;
}
.menu {
background-color: var(--menuBackgroundColor, #f0f0f0);
box-shadow: var(--menuBoxShadow, 0 1px 3px 0 rgba(0, 0, 0, .12), 0 1px 2px 0 rgba(0, 0, 0, .24));
}
.menu__list {
display: flex;
padding-left: 0;
}
.page__menu img {
float: left;
position: relative;
margin: 10px 15px 15px 10px;
display: block;
width: 450px;
max-width: 100%;
height: auto;
margin: auto;
}
#login {
display: flex;
align-items: center;
}
.menu__link {
padding: var(--menuLinkPadding, 1.5rem 2.5rem);
font-weight: 700;
text-transform: uppercase;
}
.text-underlined {
position: relative;
overflow: hidden;
will-change: color;
transition: color .25s ease-out;
}
.text-underlined::before,
.text-underlined::after {
content: "";
width: 0;
height: 3px;
background-color: var(--textUnderlinedLineColor, currentColor);
will-change: width;
transition: width .1s ease-out;
position: absolute;
bottom: 0;
}
.text-underlined::before {
left: 50%;
transform: translateX(-50%);
}
.text-underlined::after {
right: 50%;
transform: translateX(50%);
}
.text-underlined:hover::before,
.text-underlined:hover::after {
width: 100%;
transition-duration: .2s;
}
.page__custom-settings {
--menuBackgroundColor: #255785;
--menuLinkColor: #fff;
--menuLinkColorUnactive: #241c69;
--menuLinkOutlineOffset: -.5rem;
}
.button {
background-color: #e8491d;
color: white;
padding: 10px 12px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 7px 7px;
transition-duration: 0.4s;
cursor: pointer;
float: right;
}
.button:hover {
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
}
h1 {
text-align: right;
font-size: 14px;
font-weight: bold;
font-family: "Times New Roman", Times, serif;
color: white;
padding: 20px;
}

transform: rotate makes my element not be as smooth

I don't really know how to explain what I mean, but here's a photo so you can see:
The part in the circle is not really as smooth as I'd like. I have a multiple monitor setup and on another monitor the not-smoothness is really annoying. Is there any way to make it look better?
#dashboard-content {
margin-top: 10vh;
position: relative;
transition-duration: 500ms;
z-index: 1;
border-radius: 15px;
box-shadow: 0 0.25rem 1rem 0 rgba(47, 91, 234, 0.125);
}
.avatar-wrapper {
width: 100%;
margin: 0 auto;
position: relative;
z-index: 1;
border-radius: 15px 15px 0 0;
box-sizing: border-box;
padding: 30px 30px 0 30px;
background-color: #3f43fd;
overflow: hidden;
}
.avatar-wrapper::after {
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
position: absolute;
width: 150%;
height: 80px;
bottom: -45px;
left: -25%;
content: "";
background-color: #ffffff;
-webkit-transform: rotate(-3deg);
transform: rotate(-3deg);
}
.dashboard-avatar {
display: block;
margin: 0 auto;
width: 20%;
}
.dashboard-data {
display: flex;
flex-direction: column;
align-items: flex-end;
row-gap: 7.5px;
margin-right: 1rem;
}
.dashboard-name {
position: relative;
font-weight: bold;
}
.dashboard-email {
font-weight: 100;
color: gray;
}
.dashboard-line {
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
margin: 0.2rem auto 0 auto;
width: 50px;
height: 3px;
background-color: #3f43fd;
content: "";
}
.fa-diamond-custom {
color: #b9f2ff;
}
<div id="dashboard-content">
<div class="avatar-wrapper"><img class="dashboard-avatar" src="https://pluspng.com/img-png/png-user-icon-circled-user-icon-2240.png" alt="test"></div>
<div class="dashboard-data">
<div class="dashboard-name">Octavian Niculescu<div class="dashboard-line"></div>
</div>
<div class="dashboard-email">octavian.niculescu#test.com</div>
<div class="dashboard-diamonds">100<i class="fa fa-diamond fa-diamond-custom" aria-hidden="true"></i></div>
</div>
</div>
I suspect there might be some anti-aliasing setting that might help with this, but I couldn't find any.
So, what would be the best way to make that line as smooth as possible?
Thanks.
Use the blur feature to smooth the image as you want: https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/blur()
And then use a mask to hide the space that you don't want the effect to appear.
You can read this guide: https://developer.mozilla.org/en-US/docs/Web/CSS/mask-image
For more examples: https://www.w3schools.com/cssref/css3_pr_mask-image.asp
#dashboard-content {
margin-top: 10vh;
position: relative;
transition-duration: 500ms;
z-index: 1;
border-radius: 15px;
box-shadow: 0 0.25rem 1rem 0 rgba(47, 91, 234, 0.125);
}
.avatar-wrapper {
width: 100%;
margin: 0 auto;
position: relative;
z-index: 1;
border-radius: 15px 15px 0 0;
box-sizing: border-box;
padding: 30px 30px 0 30px;
background-color: #3f43fd;
overflow: hidden;
}
.avatar-wrapper::after {
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
position: absolute;
width: 150%;
height: 40px;
top: 90%;
left: -25%;
content: "";
background-color: #ffffff;
-webkit-transform: rotate(-3deg);
transform: rotate(-3deg);
}
.dashboard-avatar {
display: block;
margin: 0 auto;
width: 20%;
margin-bottom: 30px;
}
.dashboard-data {
display: flex;
flex-direction: column;
align-items: flex-end;
row-gap: 7.5px;
margin-right: 1rem;
}
.dashboard-name {
position: relative;
font-weight: bold;
}
.dashboard-email {
font-weight: 100;
color: gray;
}
.dashboard-line {
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
margin: 0.2rem auto 0 auto;
width: 50px;
height: 3px;
background-color: #3f43fd;
content: "";
}
.fa-diamond-custom {
color: #b9f2ff;
}
<div id="dashboard-content">
<div class="avatar-wrapper"><img class="dashboard-avatar" src="https://pluspng.com/img-png/png-user-icon-circled-user-icon-2240.png" alt="test"></div>
<div class="dashboard-data">
<div class="dashboard-name">Octavian Niculescu<div class="dashboard-line"></div>
</div>
<div class="dashboard-email">octavian.niculescu#test.com</div>
<div class="dashboard-diamonds">100<i class="fa fa-diamond fa-diamond-custom" aria-hidden="true"></i></div>
</div>
</div>

Creating Custom designed Upload file Button

I want to create a custom button for a file upload in a form using simple html and css.
Here is my code.
.upload-btn-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="upload-btn-wrapper">
<button class="btn">Upload a file<i style="font-size:18px" class="fa"></i></button>
<input type="file" name="myfile" />
</div>
if it is just about to design upload button cutomly then this css code is also usefull.
Here is your css
and open the snippet to check.
.upload_field input.wpcf7-file::-webkit-file-upload-button {
border: none;
color: #fff;
font-weight: 500;
background: linear-gradient(90deg, rgba(35,90,75,8) 0%, rgb(33, 169, 99) 35%, rgba(39,203,119,1) 100%);
padding: 4px 18px;
border-radius: 30px;
cursor: pointer;
box-shadow: 2px 1px 9px -3px #25c171;
}
.upload_field input.wpcf7-file::-webkit-file-upload-button:hover {
background: linear-gradient(90deg, rgba(39,203,119,1) 0%, rgba(39,203,119,1) 35%, rgba(14,90,51,1) 100%);
}
.upload_field input.wpcf7-file::-webkit-file-upload-button:focus{
outline:none;
}
.upload_field input.wpcf7-file:focus {
outline: none;
}
.upload_field {
margin-bottom: 20px;
padding-left: 5px;
border: 1px solid #e6e6e6;
padding: 15px 10px 25px;
border-radius: 20px;
}
<div class="upload_field">
<label>Please Upload Your Resume(jpg,png, pdf, doc).<br>
<span class="wpcf7-form-control-wrap file-874"><input type="file" name="file-874" size="40" class="wpcf7-form-control wpcf7-file" accept=".jpg,.png,.pdf,.doc" aria-invalid="false"></span></label>
</div>
.upload-btn-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
}
.fa {
margin-left: 10px;
padding: 10px;
background: white;
color : #0e5a33;
border-radius: 50%;
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.btn {
border: 2px solid #0e5a33;
background-color: #0e5a33;
box-shadow: 8px 8px 18px 0px rgba(84, 181, 119, 0.3) !important;
font-size: 18px;
padding: 5px 5px 5px 28px;
border-radius: 25px;
color: white;
}
.btn:before{
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
opacity: 1;
-webkit-transform: translate(-105%, 0);
transform: translate(-105%, 0);
background-color: rgba(255, 255, 255, 0.8);
}
.btn:hover:before{
opacity: 0;
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
.upload-btn-wrapper input[type=file] {
font-size: 100px;
position: absolute;
left: 0;
top: 0;
opacity: 0;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="upload-btn-wrapper">
<button class="btn">Upload a file<i style="font-size:18px" class="fa"></i></button>
<input type="file" name="myfile" />
</div>
<!DOCTYPE html>
<html>
<head>
<style>
.button {
display: inline-block;
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
</style>
</head>
<body>
<h2>Animated Button</h2>
<button class="button" style="vertical-align:middle"><span>Upload File </span>
</button>
</body>
</html>

How can i handle macOs safari overflow:hidden; problem

I've made animated scroll to up button. When user hover on the button, up arrow animation plays in side of the button. I've add overflow:hidden; code for hidden overflowed arrow animation out side the button area. This approach works on chrome, opera, firefox. But outside the button arrow animation don't hide on macOs safari. How can i hide arrow animation out side the button area on macOs safari.
Sass(Scss)
// COLOR VARIABLES
$color-white: #fff;
$color-gray-100: #f8f9fa;
$color-gray-200: #e9ecef;
$color-gray-300: #dee2e6;
$color-gray-400: #ced4da;
$color-gray-500: #999;
$color-gray-600: #7A8288;
$color-gray-700: #52575C;
$color-gray-800: #3A3F44;
$color-gray-900: #272B30;
$color-black: #000;
$sidebar_opacity: 0.9;
#mixin flex-vCenter($justify-content:center) {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: $justify-content;
}
////////////////// Animation //////////////////
#keyframes move_up {
from {
transform: translateY(4rem);
}
to {
transform: translateY(-4rem);
}
}
*,
*::after,
*::before {
margin: 0;
padding: 0;
box-sizing: inherit;
}
html {
// This defines what 1rem is
font-size: 62.5%; //1 rem = 10px; 10px/16px = 62.5%
box-sizing: border-box;
}
body {
font-weight: 400;
line-height: 1.6;
background-color: $color-gray-300;
}
.wrapper{
position: relative;
height: 50rem;
width: 50rem;
top:1rem;
left:10rem;
background-color: $color-gray-600;
& &__scroll_top {
position: absolute;
bottom: 3rem;
right: 3rem;
}
}
.scroll_top__btn {
&,
&:link,
&:visited {
#include flex-vCenter;
cursor: pointer;
opacity: $sidebar_opacity - .5;
background-color: $color-gray-200;
height: 4.5rem;
width: 4.5rem;
display: block;
border-radius: 5px;
transition: all .2s;
//Change for the <button> element
border: none;
overflow:hidden;
}
&:hover {
transform: translateY(-5px);
opacity: $sidebar_opacity;
}
&:active,
&:focus {
outline: none;
transform: translateY(-1px);
}
&-icon{
height: 2.5rem;
width: 2.5rem;
fill: $color-gray-900;
filter: drop-shadow( 0 5px 2px rgba($color-black, .5));
}
&:hover &-icon{
animation: move_up .5s linear infinite;
}
}
#keyframes move_up {
from {
transform: translateY(4rem);
}
to {
transform: translateY(-4rem);
}
}
*, *::after, *::before {
margin: 0;
padding: 0;
box-sizing: inherit;
}
html {
font-size: 62.5%;
box-sizing: border-box;
}
body {
font-weight: 400;
line-height: 1.6;
background-color: #dee2e6;
}
.wrapper {
position: relative;
height: 50rem;
width: 50rem;
top: 1rem;
left: 10rem;
background-color: #7a8288;
}
.wrapper .wrapper__scroll_top {
position: absolute;
bottom: 3rem;
right: 3rem;
}
.scroll_top__btn, .scroll_top__btn:link, .scroll_top__btn:visited {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
cursor: pointer;
opacity: 0.4;
background-color: #e9ecef;
height: 4.5rem;
width: 4.5rem;
display: block;
border-radius: 5px;
transition: all 0.2s;
border: none;
overflow: hidden;
}
.scroll_top__btn:hover {
transform: translateY(-5px);
opacity: 0.9;
}
.scroll_top__btn:active, .scroll_top__btn:focus {
outline: none;
transform: translateY(-1px);
}
.scroll_top__btn-icon {
height: 2.5rem;
width: 2.5rem;
fill: #272b30;
filter: drop-shadow(0 5px 2px rgba(0, 0, 0, .5));
}
.scroll_top__btn:hover .scroll_top__btn-icon {
animation: move_up 0.5s linear infinite;
}
<svg aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-arrow-up" viewBox="0 0 32 32">
<title>arrow-up</title>
<path d="M16 1l-15 15h9v16h12v-16h9z"></path>
</symbol>
</defs>
</svg>
<div class="wrapper">
<div class="wrapper__scroll_top">
<button class="scroll_top__btn" type="button">
<svg class="scroll_top__btn-icon">
<use xlink:href="#icon-arrow-up" />
</svg>
</button>
</div>
</div>
Here's the solution, I've simplified the syntax for you a little bit
This is your SCSS, the code snippet has its compiled form
// COLOR VARIABLES
$color-white: #fff;
$color-gray-100: #f8f9fa;
$color-gray-200: #e9ecef;
$color-gray-300: #dee2e6;
$color-gray-400: #ced4da;
$color-gray-500: #999;
$color-gray-600: #7A8288;
$color-gray-700: #52575C;
$color-gray-800: #3A3F44;
$color-gray-900: #272B30;
$color-black: #000;
$sidebar_opacity: 0.9;
#mixin flex-vCenter($justify-content:center) {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: $justify-content;
}
////////////////// Animation //////////////////
#keyframes move_up {
from {
transform: translateY(4rem);
}
to {
transform: translateY(-4rem);
}
}
*,
*::after,
*::before {
margin: 0;
padding: 0;
box-sizing: inherit;
}
html {
// This defines what 1rem is
font-size: 62.5%; //1 rem = 10px; 10px/16px = 62.5%
box-sizing: border-box;
}
body {
font-weight: 400;
line-height: 1.6;
background-color: $color-gray-300;
}
.wrapper{
position: relative;
height: 30rem;
width: 30rem;
top:1rem;
left:10rem;
background-color: $color-gray-600;
}
.scroll_top__btn {
display: block;
text-align: center;
position: absolute;
bottom: 3rem;
right: 3rem;
&,
&:link,
&:visited {
#include flex-vCenter;
cursor: pointer;
opacity: $sidebar_opacity - .5;
background-color: $color-gray-200;
height: 4.5rem;
width: 4.5rem;
display: block;
border-radius: 5px;
transition: all .2s;
border: none;
overflow:hidden;
}
&:hover {
transform: translateY(-5px);
opacity: $sidebar_opacity;
}
&:active,
&:focus {
outline: none;
transform: translateY(-1px);
}
&-icon{
transform: translateY(0.8rem);
height: 2.5rem;
width: 2.5rem;
fill: $color-black;
filter: drop-shadow( 0 5px 2px rgba($color-black, .5));
}
&:hover &-icon{
animation: move_up .5s linear infinite;
}
}
#keyframes move_up {
from {
transform: translateY(4rem);
}
to {
transform: translateY(-4rem);
}
}
*,
*::after,
*::before {
margin: 0;
padding: 0;
box-sizing: inherit;
}
html {
font-size: 62.5%;
box-sizing: border-box;
}
body {
font-weight: 400;
line-height: 1.6;
background-color: #dee2e6;
}
.wrapper {
position: relative;
height: 30rem;
width: 30rem;
top: 1rem;
left: 10rem;
background-color: #7A8288;
}
.scroll_top__btn {
display: block;
text-align: center;
position: absolute;
bottom: 3rem;
right: 3rem;
}
.scroll_top__btn, .scroll_top__btn:link, .scroll_top__btn:visited {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
cursor: pointer;
opacity: 0.4;
background-color: #e9ecef;
height: 4.5rem;
width: 4.5rem;
display: block;
border-radius: 5px;
transition: all .2s;
border: none;
overflow: hidden;
}
.scroll_top__btn:hover {
transform: translateY(-5px);
opacity: 0.9;
}
.scroll_top__btn:active, .scroll_top__btn:focus {
outline: none;
transform: translateY(-1px);
}
.scroll_top__btn-icon {
transform: translateY(0.8rem);
height: 2.5rem;
width: 2.5rem;
fill: #000;
filter: drop-shadow(0 5px 2px rgba(0, 0, 0, 0.5));
}
.scroll_top__btn:hover .scroll_top__btn-icon {
animation: move_up .5s linear infinite;
}
<svg aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-arrow-up" viewBox="0 0 32 32">
<title>arrow-up</title>
<path d="M16 1l-15 15h9v16h12v-16h9z"></path>
</symbol>
</defs>
</svg>
<div class="wrapper">
<a href="javascript:void;" class="scroll_top__btn" type="button">
<svg class="scroll_top__btn-icon">
<use xlink:href="#icon-arrow-up" />
</svg>
</a>
</div>