Custom shaped buttons for menu - html

I am trying to achieve this effect which I got on image. I am having trouble in creating custom shapes. Could someone assist me with this please?
body {
margin: 0;
}
.container {
display: flex;
width: 100%;
height: 100vh;
}
.menu {
background: lightgray;
flex: 0.1;
display: flex;
flex-direction: column;
padding-left: 15px;
}
.numbers {
background: #79726c;
border: none;
transform: skewY(10deg);
}
.content {
flex: 1;
background: blue;
}
<div class="container">
<div class="menu">
<button class="first">Start
</button>
<button class="numbers">1
</button>
<button class="numbers">2
</button>
</div>
<div class="content">
</div>
</div>

If you were only interested in the visual component, then it turned out quite similar:
body {
margin: 0;
display: flex;
justify-content: space-around;
align-items: center;
min-height: 100vh;
background-color: #312a28;
background-image: url("https://cdn.pixabay.com/photo/2016/11/27/05/02/texture-1862140_960_720.jpg");
}
.container {
position: relative;
display: flex;
height: 626px; width: 70vw;
}
.tabs {
position: relative;
top: 124px;
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
height: 464px; width: 66px;
user-select: none;
}
.tabs>input {
position: absolute !important;
height: 1px !important;
width: 1px !important;
border: none !important;
padding: 0 !important;
margin: 0 !important;
white-space: nowrap !important;
overflow: hidden !important;
clip: rect(1px, 1px, 1px, 1px) !important;
}
.tab {
position: relative;
left: 6px;
height: 34px; width: 66px;
border: none;
box-sizing: border-box;
font-size: 40px; line-height: 34px;
font-family: sans-serif; font-weight: bold;
text-align: center;
color: #f9f9f7;
background-color: #79726c;
filter: drop-shadow(-2px 8px 4px #0008);
transition: 0.3s ease;
}
.tab:nth-of-type(1) { z-index: 6; }
.tab:nth-of-type(2) { z-index: 5; }
.tab:nth-of-type(3) { z-index: 4; }
.tab:nth-of-type(4) { z-index: 3; }
.tab:nth-of-type(5) { z-index: 2; }
.tab:nth-of-type(6) { z-index: 1; }
.tab:nth-of-type(7) { z-index: 0; }
.tab::before,
.tab::after {
content: "";
position: absolute;
left: 0; z-index: -1;
width: 100%;
border-radius: 6px 4px 4px 6px;
background-color: inherit;
background-image: inherit;
}
.tab::before {
bottom: 16px; height: 126px;
transform: skewy(-28deg);
}
.tab::after {
top: 16px; height: 40px;
transform: skewy(28deg);
}
.tabs > input:not(:checked) + .tab:hover {
background-color: #aba5a0;
cursor: pointer;
}
.tabs > input:checked + .tab {
left: 0; z-index: 7;
background-color: #d8cec1;
background-image: url("https://cdn.pixabay.com/photo/2016/11/08/03/16/seamless-1807376_960_720.jpg");
color: #393534;
}
.tab .vertical {
position: absolute;
left: 10px; top: -85px;
transform: rotate(-90deg);
font-size: 12px;
text-transform: uppercase;
text-shadow: 0 0 2px currentcolor;
}
.content {
position: relative;
left: -3px; z-index: 8;
flex: 1;
border-radius: 6px;
background-color: #d8cec1;
background-image: url("https://cdn.pixabay.com/photo/2016/11/08/03/16/seamless-1807376_960_720.jpg");
box-shadow: 2px 13px 6px -4px #0008;
}
<section class="container">
<div class="tabs">
<input type="radio" name="tabs" id="tab0" checked><label for="tab0" class="tab"><span class="vertical">Start</span></label>
<input type="radio" name="tabs" id="tab1"><label for="tab1" class="tab">1</label>
<input type="radio" name="tabs" id="tab2"><label for="tab2" class="tab">2</label>
<input type="radio" name="tabs" id="tab3"><label for="tab3" class="tab">3</label>
<input type="radio" name="tabs" id="tab4"><label for="tab4" class="tab">4</label>
<input type="radio" name="tabs" id="tab5"><label for="tab5" class="tab">5</label>
<input type="radio" name="tabs" id="tab6"><label for="tab6" class="tab">6</label>
</div>
<div class="content"></div>
</section>

enter image description here
hello,I tried a little and made this one.I think this structure can be useful for you.
Code:
enter code here
<div class="container">
<div class="menu">
<button class="first">Start
</button>
<button class="numbers" id="btn-top-shadow">1
</button>
<button class="numbers">2
</button>
<button class="numbers">3
</button>
<button class="numbers">4
</button>
<button class="numbers">5
</button>
<button class="numbers">6
</button>
<button class="numbers">7
</button>
</div>
<div class="content">
</div>
</div>
body {
margin: 0;
}
.container {
display: flex;
width: 100%;
height: 100vh;
}
.first
{
transform: rotate(270deg) scale(4.5) ;
position: relative;
top:10%;
font-size: 4px;
}
.menu {
background: lightgray;
flex: 0.1;
display: flex;
flex-direction: column;
padding-left: 15px;
}
.numbers {
background: #79726c;
border: none;
transform: skewY(10deg);
width: 38%;
position: relative;
left: 38px;
top: 110px;
color: white;
text-shadow: 0px 7px 3px black;
height: 5%;
border-bottom: 0.4px solid black
}
#btn-top-shadow
{
box-shadow: 0px -7px 7px black;
}
.content {
flex: 1;
background: blue;
}

To achieve the shape you want on the first button. Use two buttons!
Assign the same scripts!
https://www.codegrepper.com/code-examples/css/css+triangle+button
Here's some details on how to make the triangle part!
Good luck!

Related

Why won't the scrolling container display in my popup window, but works outside of it?

I have a popup window (within the same page) which I'm attempting to put a container which scrolls horizontally into, yet it distorts the popup window and does not display anything other than the scrollbar. I'm honestly at a loss, can anyone help me here? I've looked around for solutions but I can't find anything that I can see applies to my problem.
If anyone can help, or point me in the right direction, I'd be really grateful. The scrollbar works perfectly fine when isolated, but inside the window shows like this:
Standalone:
My HTML (popup window with scrollbar inside)
<div id="formula-popup" class="popup-window">
<div>
<a onclick="closeFormulaWindow()" title="Close" class="close">X</a>
<span id="ftitle" class="title1"></span>
<form method="post" id="formulaform" name="edit">
<span>Current Formula</span>
<p id="current-formula" class="formula">Existing formula</p>
<input id="id-passer" type="hidden" name="formula-id" value="">
<!--sort out horizontal scrollbar from bookmarks here later-->
<input onclick="refreshWindow()" name="edit-formula" type="submit" value="Confirm">
</form>
<div class="h-scrollbar">
<section class="h-scrollbar-container">
<div class="outer-wrapper">
<div class="inner-wrapper">
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
</div>
</div>
<div class="pseudo-track"></div>
</section>
</div>
</div>
My CSS:
.scrollbar-container {
display: flex;
flex-direction: row;
}
.h-scrollbar {
display: flex;
max-width: 30vw;
padding: 0px 10px;
height: 20vh;
align-items: center;
justify-content: center;
overflow: hidden;
flex-shrink: 0;
}
.h-scrollbar-container {
width: 100%;
}
.outer-wrapper {
max-width: 100vw;
overflow-x: scroll;
position: relative;
scrollbar-color: #d5ac68 #f1db9d;
scrollbar-width: thin;
-ms-overflow-style: none;
}
.pseudo-track {
background-color: #f1db9d;
height: 2px;
width: 100%;
position: relative;
top: -3px;
z-index: -10;
}
.outer-wrapper::-webkit-scrollbar {
height: 5px;
}
.outer-wrapper::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 0px rgba(0, 0, 0, 0);
}
.outer-wrapper::-webkit-scrollbar-thumb {
height: 5px;
background-color: #d5ac68;
}
.outer-wrapper::-webkit-scrollbar-thumb:hover {
background-color: #f1db9d;
}
.outer-wrapper::-webkit-scrollbar:vertical {
display: none;
}
.inner-wrapper {
display: flex;
padding-bottom: 10px;
}
.pseudo-item {
height: 30px;
width: 80px;
margin-right: 15px;
flex-shrink: 0;
background-color: gray;
}
.pseudo-item:nth-of-type(2n) {
background-color: lightgray;
}
.popup-window {
position: fixed;
font-family: Arial, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: none;
}
.popup-window div {
width: 40vw;
height: 30vw;
position: relative;
margin: 10% auto 30%;
border-radius: 10px;
background: #213B54;
padding-top: 2vh;
padding-left: 1vw;
padding-right: 1vw;
padding-bottom: 2vh;
display: flex;
flex-direction: column;
}
.close {
font: Arial, sans-serif;
background: #067A9F;
color: #B5E5E7;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
border-radius: 12px;
box-shadow: 1px 1px 3px #000;
cursor: pointer;
}
.popup-window div .title1 {
font-family: Arial, sans-serif;
font-weight: normal;
font-size: 36px;
color: #EE6802;
align-self: center;
}
.popup-window form input[type=submit]:hover {
opacity: 0.8;
}
.popup-window form span {
color: #EE6802;
font-size: 22px;
}
.popup-window form {
display: flex;
flex-direction: column;
font-family: Arial, sans-serif;
}
.popup-window form span, input {
width: 100%;
}
.popup-window form input[type=submit] {
width: 20%;
background-color: #067A9F;
color: #213B54;
padding: 14px 0;
cursor: pointer;
border: none;
}
I found the solution, it was that I forgot to select an element inside the window properly and instead it was selecting all divs and so overriding the CSS properties.

Fully responsive progress bar

I have to create a progress bar that has to be fully responsive. In order to be responsive I don't want the progress bar class to have a fixed width, but when I put auto in width, line of progress bar is detached from the star also if I give to them auto width
Fixed width: look good
Width auto
First how can I fix this issue, and perhaps someone can help me achieve this progress bar to be responsive on mobile also so that the line of progress bar will be vertical.
.progress-bar {
width: 750px;
display: flex;
margin: 40px 0;
}
.progress-bar .step {
text-align: center;
width: 100%;
}
.progress-bar .step .bullet {
position: relative;
height: 25px;
width: 25px;
display: inline-block;
}
.progress-bar .step:last-child .bullet:before,
.progress-bar .step:last-child .bullet::after {
display: none;
}
.progress-bar .step .bullet:before,
.progress-bar .step .bullet::after {
position: absolute;
content: "";
height: 3px;
right: -136px;
bottom: 11px;
width: 142px;
background: #C1C1C1;
}
.active-bullet {
z-index: 1;
}
.active-check {
z-index: 2;
}
<div class="progress-bar">
<div class="step">
<div class="bullet active-bullet">
<img src="star-pb-active.svg">
</div>
<div class="check active-check" style="
border-bottom: 2px solid black;
padding: 2px;
DISPLAY: table-cell;
LEFT: 40px;
POSITION: relative;
">Order placed</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Jewerly Creation</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Packing & Quality Control</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Shipped</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Estimated Delivery</div>
</div>
</div>
You should try taking a look at the flex-grow property from Flexbox.
By giving display: flex to the parent, and flex-grow: 1 to the children, you should be able to make every step be the same size and take all the width of their container.
It works the way you want, in fixed or auto width.
.progress-bar {
width: auto;
display: flex;
margin: 40px 0;
}
.progress-bar .step {
text-align: center;
position: relative;
isolation: isolate;
width: 100%;
}
.progress-bar .step::after {
content: "";
position: absolute;
z-index: -1;
height: 3px;
top: 12px; /* 1/2 of .bullet's height */
width: 100%;
background: #C1C1C1;
}
.progress-bar .step:last-child::after {
display: none;
}
.progress-bar .step .bullet {
position: relative;
height: 25px;
width: 25px;
display: inline-block;
}
.active-bullet {
z-index: 1;
}
.active-check {
z-index: 2;
}
Added pseudo element on the parent of .bullet.
Also you don't need ::before, one of those pseudo elements was enough.
try below code, your code some confusion.
use flex in css
below sample add one button which goes your activity to next step
it is fully responsive - on desktop this code horizontal and on mobile this code show vertical progressbar.
just use small js, css and for tick icon font awesome js.
if any query comment it.
let step = 'step1';
const step1 = document.getElementById('step1');
const step2 = document.getElementById('step2');
const step3 = document.getElementById('step3');
const step4 = document.getElementById('step4');
function next() {
if (step === 'step1') {
step = 'step2';
step1.classList.remove("is-active");
step1.classList.add("is-complete");
step2.classList.add("is-active");
} else if (step === 'step2') {
step = 'step3';
step2.classList.remove("is-active");
step2.classList.add("is-complete");
step3.classList.add("is-active");
} else if (step === 'step3') {
step = 'step4d';
step3.classList.remove("is-active");
step3.classList.add("is-complete");
step4.classList.add("is-active");
} else if (step === 'step4d') {
step = 'complete';
step4.classList.remove("is-active");
step4.classList.add("is-complete");
} else if (step === 'complete') {
step = 'step1';
step4.classList.remove("is-complete");
step3.classList.remove("is-complete");
step2.classList.remove("is-complete");
step1.classList.remove("is-complete");
step1.classList.add("is-active");
}
}
.progress-bar {
position: relative;
display: flex;
}
.progress-bar .progress-track {
position: absolute;
top: 5px;
width: 100%;
height: 5px;
background-color: #dfe3e4;
z-index: -1;
}
.progress-bar .progress-step {
position: relative;
width: 100%;
font-size: 12px;
text-align: center;
}
.progress-bar .progress-step:last-child:after {
display: none;
}
.progress-bar .progress-step:before {
content: "\f00c";
display: flex;
margin: 0 auto;
margin-bottom: 10px;
width: 10px;
height: 10px;
background: #fff;
border: 4px solid #dfe3e4;
border-radius: 100%;
color: transparent;
}
.progress-bar .progress-step:after {
content: "";
position: absolute;
top: 6px;
left: 50%;
width: 0%;
transition: width 1s ease-in;
height: 5px;
background: #dfe3e4;
z-index: -1;
}
#media screen and (max-width:700px) {
.progress-bar {
position: relative;
display: inline-block;
}
.progress-bar .progress-track {
position: absolute;
top: -10px;
width: 100%;
height: 5px;
background-color: #dfe3e4;
z-index: -1;
transform: rotate(90deg);
}
.progress-bar .progress-step {
position: relative;
width: 100%;
font-size: 12px;
text-align: center;
}
.progress-bar .progress-step:last-child:after {
display: none;
}
.progrestext
{
left: 44px;
position: absolute;
top: 0px;
}
.progress-bar .progress-step:after {
content: "";
position: absolute;
top: 20px;
left: 0%;
width: 0%;
transition: width 1s ease-in;
height: 5px;
background: #dfe3e4;
z-index: -1;
transform: rotate(90deg);
}
}
.progress-bar .progress-step.is-active {
color: #2183dd;
}
.progress-bar .progress-step.is-active:before {
border: 4px solid #777;
animation: pulse 2s infinite;
}
.progress-bar .progress-step.is-complete {
color: #009900;
}
.progress-bar .progress-step.is-complete:before {
font-family: FontAwesome;
font-size: 10px;
color: #fff;
background: #009900;
border: 4px solid transparent;
}
.progress-bar .progress-step.is-complete:after {
background: #2183dd;
animation: nextStep 1s;
animation-fill-mode: forwards;
}
#keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(33, 131, 221, 0.8);
}
70% {
box-shadow: 0 0 0 10px rgba(33, 131, 221, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(33, 131, 221, 0);
}
}
#keyframes nextStep {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
.container {
margin: 50px 100px;
}
button {
position: absolute;
right: 50px;
bottom: 20px;
cursor: pointer;
}
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://use.fontawesome.com/c47bc38e87.js"></script>
<div class="container">
<div class="progress-bar">
<div class="progress-track"></div>
<div id="step1" class="progress-step">
<div class="progrestext">placed</div>
</div>
<div id="step2" class="progress-step">
<div class="progrestext">Creation</div>
</div>
<div id="step3" class="progress-step">
<div class="progrestext">Packing</div>
</div>
<div id="step4" class="progress-step">
<div class="progrestext">Delivered</div>
</div>
</div>
<button onClick=next()>Next Step</button>
</div>

Why my child container is over lapping on main container [duplicate]

This question already has answers here:
How to make an element width: 100% minus padding?
(15 answers)
Closed 12 months ago.
Can anyone tell me how to solve this problem, As you can see my .tab
class is set to 100% width and it's overlapping on the
.main-container class? I also use overflow on my main container
however it began having a scroll can any tell me what is the correct
way to solve this problem? Thank you
.main-container {
border: 1px solid #D8D8D8;
border-radius: 2px;
width: 99%;
margin: 0 auto;
min-height: 10px;
/* overflow: auto; */
margin-top: 3px;
background: blue;
padding: 10px;
}
.tabs {
position: relative;
padding: 10px;
display: inline-block;
background-color: #f2f7fd;
border-radius: 6px;
width: 100%;
border: 1px solid transparent;
color: #333333;
}
.tabs-title {
margin-bottom: 6px;
font-size: 18px;
font-weight: 600;
color: #000000;
line-height: 22px;
padding: 0 2px;
}
.tabs-subtitle {
margin-bottom: 15px;
position: relative;
padding: 0 4px;
line-height: 18px;
}
.tabs-subtitle+hr {
height: 1px;
border: none;
background-color: #7a8a9a;
display: block;
margin-bottom: 15px;
}
.tabs-content {
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.tabs-rdb {
display: none;
order: 1;
}
.tabs-lbl {
position: relative;
top: 0;
padding: 8px 14px;
padding-bottom: 10px;
cursor: pointer;
background-color: transparent;
display: inline-block;
border-radius: 6px 6px 0 0;
font-size: 13px;
order: 2;
font-weight: normal;
user-select: none;
color: #000000;
}
.tabs.tabs-lbl-bold .tabs-lbl {
font-weight: bold;
}
.tabs-rdb+.tabs-lbl:before {
content: '';
position: absolute;
width: 0;
height: 1px;
border: 6px;
background-color: #2575c4;
bottom: 2px;
left: 50%;
transform: translateX(-50%);
transition: .32s ease width;
opacity: 0;
}
.tabs.tabs-lbl-bold .tabs-rdb+.tabs-lbl:before {
height: 2px;
}
.tabs-lbl:hover {
color: #2575c4;
}
.tabs-lbl:first-of-type {
margin-left: 16px;
}
.tabs-lbl:last-of-type {
margin-right: 16px;
}
.tabs-rdb:checked+.tabs-lbl {
background-color: #ffffff;
color: #2575c4;
box-shadow: 0 1px 3px rgba(0, 0, 0, .14);
}
.tabs-rdb:checked+.tabs-lbl+.tabs-text {
display: block;
}
.tabs-rdb:checked+.tabs-lbl:before {
width: 32%;
opacity: 1;
}
.tabs-text {
display: none;
top: 0;
order: 999;
padding: 10px;
background-color: #ffffff;
border-radius: 6px;
line-height: 18px;
box-shadow: 0 0px 8px -4px rgba(0, 0, 0, .24);
width: 100%;
z-index: 1;
min-height: 38px;
}
<div class="main-container">
<div class="tabs tabs-lbl-bold">
<div class="tabs-title">Main Title (Optional)</div>
<div class="tabs-subtitle">Subtitle Lorem ipsum dolor at met (Optional).</div>
<hr>
<div class="tabs-content">
<input id="nkTabs_a_1" type="radio" class="tabs-rdb" checked name="tabs-a">
<label for="nkTabs_a_1" class="tabs-lbl">Home</label>
<div class="tabs-text">This area is for Home tab.</div>
<!-- -->
<input id="nkTabs_a_2" type="radio" class="tabs-rdb" name="tabs-a">
<label for="nkTabs_a_2" class="tabs-lbl">About</label>
<div class="tabs-text">
This area is for About tab. This area is for About tab. This area is for About tab. This area is for About tab. This area is for About tab.
</div>
<!-- -->
<input id="nkTabs_a_3" type="radio" class="tabs-rdb" name="tabs-a">
<label for="nkTabs_a_3" class="tabs-lbl">Help</label>
<div class="tabs-text">This area is for Help tab. This area is for Help tab.</div>
</div>
</div>
</div>
This overflow is caused by the box-sizing. Just add .tabs { box-sizing: border-box; } and the issue should be fixed.
The default value of box-sizing: content-box does not include the paddings and border. As such 100% width of the parent + paddings and border will always overflow! As such you have an overflow by 22px without border-box
PS: To stop the horizontal overflow of the viewport you should use width: auto instead of width: 99% on the wrapping parent element.
.tabs {
box-sizing: border-box;
}
/* original CSS */
.main-container {
border: 1px solid #D8D8D8;
border-radius: 2px;
width: 99%;
margin: 0 auto;
min-height: 10px;
/* overflow: auto; */
margin-top: 3px;
background: blue;
padding: 10px;
}
.tabs {
position: relative;
padding: 10px;
display: inline-block;
background-color: #f2f7fd;
border-radius: 6px;
width: 100%;
border: 1px solid transparent;
color: #333333;
}
.tabs-title {
margin-bottom: 6px;
font-size: 18px;
font-weight: 600;
color: #000000;
line-height: 22px;
padding: 0 2px;
}
.tabs-subtitle {
margin-bottom: 15px;
position: relative;
padding: 0 4px;
line-height: 18px;
}
.tabs-subtitle+hr {
height: 1px;
border: none;
background-color: #7a8a9a;
display: block;
margin-bottom: 15px;
}
.tabs-content {
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.tabs-rdb {
display: none;
order: 1;
}
.tabs-lbl {
position: relative;
top: 0;
padding: 8px 14px;
padding-bottom: 10px;
cursor: pointer;
background-color: transparent;
display: inline-block;
border-radius: 6px 6px 0 0;
font-size: 13px;
order: 2;
font-weight: normal;
user-select: none;
color: #000000;
}
.tabs.tabs-lbl-bold .tabs-lbl {
font-weight: bold;
}
.tabs-rdb+.tabs-lbl:before {
content: '';
position: absolute;
width: 0;
height: 1px;
border: 6px;
background-color: #2575c4;
bottom: 2px;
left: 50%;
transform: translateX(-50%);
transition: .32s ease width;
opacity: 0;
}
.tabs.tabs-lbl-bold .tabs-rdb+.tabs-lbl:before {
height: 2px;
}
.tabs-lbl:hover {
color: #2575c4;
}
.tabs-lbl:first-of-type {
margin-left: 16px;
}
.tabs-lbl:last-of-type {
margin-right: 16px;
}
.tabs-rdb:checked+.tabs-lbl {
background-color: #ffffff;
color: #2575c4;
box-shadow: 0 1px 3px rgba(0, 0, 0, .14);
}
.tabs-rdb:checked+.tabs-lbl+.tabs-text {
display: block;
}
.tabs-rdb:checked+.tabs-lbl:before {
width: 32%;
opacity: 1;
}
.tabs-text {
display: none;
top: 0;
order: 999;
padding: 10px;
background-color: #ffffff;
border-radius: 6px;
line-height: 18px;
box-shadow: 0 0px 8px -4px rgba(0, 0, 0, .24);
width: 100%;
z-index: 1;
min-height: 38px;
}
<div class="main-container">
<div class="tabs tabs-lbl-bold">
<div class="tabs-title">Main Title (Optional)</div>
<div class="tabs-subtitle">Subtitle Lorem ipsum dolor at met (Optional).</div>
<hr>
<div class="tabs-content">
<input id="nkTabs_a_1" type="radio" class="tabs-rdb" checked name="tabs-a">
<label for="nkTabs_a_1" class="tabs-lbl">Home</label>
<div class="tabs-text">This area is for Home tab.</div>
<!-- -->
<input id="nkTabs_a_2" type="radio" class="tabs-rdb" name="tabs-a">
<label for="nkTabs_a_2" class="tabs-lbl">About</label>
<div class="tabs-text">
This area is for About tab. This area is for About tab. This area is for About tab. This area is for About tab. This area is for About tab.
</div>
<!-- -->
<input id="nkTabs_a_3" type="radio" class="tabs-rdb" name="tabs-a">
<label for="nkTabs_a_3" class="tabs-lbl">Help</label>
<div class="tabs-text">This area is for Help tab. This area is for Help tab.</div>
</div>
</div>
</div>

positioning a button inside the input field

I want to place a button inside my input exactly like this:
So far I have the input but I'm unable to find a solution to place the button properly.
.realoutercontainer {
padding: 10% 0;
position:relative;
}
.outercontainer {
direction: rtl;
text-align: center;
position: relative;
z-index: 1;
max-width: 1040px;
margin: 0 auto;
width: 100%;
box-sizing: border-box;
border-bottom: 2px solid rgba(207,215,223,.25);
position: relative;
background-color: #fff;
border-radius: 30px;
padding: 30px 40px 10px 40px;
-webkit-box-shadow: 0 30px 60px -12px rgba(50,50,93,.25),0 18px 36px -18px rgba(0,0,0,.3);
box-shadow: 0 30px 60px -12px rgba(50,50,93,.25),0 18px 36px -18px rgba(0,0,0,.3);
box-sizing: border-box;
color: #6c6770;
font-family: "Vazir";
}
.realoutercontainer.settings{
padding: 2% 0;
}
.settings .outercontainer {
max-width: 100%;
width: 94%;
height: 600px;
padding: 100px;
padding-top: 50px;
}
.settings-input {
margin: 50px 0;
display: flex;
justify-content: center;
}
.settings-input input {
display: inline-block;
direction: ltr;
text-align: center;
outline: none;
width: 300px;
background: #ededed;
color: #743db0;
padding: 5px 5px;
border-radius: 3px;
border: solid 1px;
border-color: transparent;
transition: all 0.3s ease-in;
}
.settings-input input:focus {
color: #8e5bc5;
background: #fff;
border-color: #e7572c;
}
.settings-input .input-field {
display: flex;
flex-direction: column ;
}
.settings-input .uname{
align-self: flex-start;
margin-bottom: 3px;
}
<div class="realoutercontainer settings">
<div class="outercontainer">
<div class="settings-input">
<div class="input-field">
<div for="fname" class="uname">نام کاربری :</div>
<div><input type="text" id="fname" name="fname" placeholder="user_1252442"/></div>
<button type="submit">ویرایش</button>
</div>
</div>
</div>
</div>
div,
form,
input {
position: relative;
}
.container {
width: 400px;
display: flex;
padding: 0.5rem;
align-items: center;
background-color: coral;
}
input {
width: 100%;
padding: 1rem;
border: 1px solid black;
}
button {
position: absolute;
right: 1rem;
}
<form>
<label> نام کاربری : </label>
<br />
<div class="container">
<input type="text" placeholder="Some Text..." />
<button type="submit"> Submit </button>
</div>
</form>
You can change the styles or whatever you want accordingly. I showed how its done.
Here goes, follow the code, I hope it helps you.
It is not styled, it is in raw form.
input {
position: absolute;
height: 2.3em;
}
.group-wrapper {
width: 50em;
display: flex;
align-items: center;
}
.content {
padding-left: 7em;
background: #EDEDED;
border: none;
border-radius: 0.2em;
}
.uname {
margin:0 9em 0.5em;
display: inline-block;
-moz-transform: scale(-1, 1);
-webkit-transform: scale(-1, 1);
transform: scale(-1, 1);
}
button {
position: relative;
justify-content: start;
color: #E1E5ED;
background: #ED1C24;
padding: 0.4em;
margin-left: 0.5em;
border: none;
}
<form>
<label for="user" class="uname">نام کاربری :</label>
<div class="group-wrapper">
<input id="user" class="content" type="text" placeholder="user_1252442" />
<button type="submit">ویرایش</button>
</div>
</form>
Shamelessly borrowing from #Kunal, this version puts the button on the left as desired:
div,
form,
input {
position: relative;
}
.container {
width: 400px;
display: flex;
padding: 0.5rem;
align-items: center;
}
input {
width: 100%;
padding: 1rem;
padding-left: 100px;
border: 1px solid black;
}
button {
position: absolute;
left: 1rem;
}
<form>
<label> نام کاربری : </label>
<br />
<div class="container">
<input type="text" placeholder="Some Text..." />
<button> My button </button>
</div>
</form>

Making expandable material search bar with algolia autocomplete

I am using algolia autocomplete in my app. And I would like to build a search bar that expands like the expandable example on this page. I have a layout with a header bar that has a search input for bigger screens. On small screens I only have a magnifying glass icon, that on click toggles another header with a search bar, that I initially have it hidden. Here is the fiddle, which I wasn't able to get working, but hope it can still give you some overview. This is the layout:
<header class="mdc-toolbar mdc-toolbar--fixed toolbar--custom">
<div class="mdc-toolbar__row">
<section class="menu mdc-toolbar__section mdc-toolbar__section--align-start">
menu
<span class="mdc-toolbar__title">Title</span>
</section>
<section class="mdc-toolbar__section">
<form action="/search" method="get" class="search-field-desktop">
<div class="mdc-text-field mdc-text-field--box mdc-text-field--with-leading-icon autocomplete-search-field">
<i class="material-icons mdc-text-field__icon" tabindex="0">search</i>
<input name="q"
type="text"
class="mdc-text-field__input search-input-js aa-input-search"
placeholder="Search for players and videos ..."
aria-label="Full-Width Text Field">
</div>
</form>
</section>
<section class="mdc-toolbar__section mdc-toolbar__section--align-end" role="toolbar">
search
more_vert
</section>
</div>
</header>
<header class="search-field-phone mdc-toolbar mdc-toolbar--fixed toolbar--custom">
<div class="mdc-toolbar__row">
<a id="search-input-close" class="material-icons mdc-toolbar__menu-icon" tabindex="0">arrow_back</a>
<form action="/search" method="get">
<div class="mdc-text-field mdc-text-field--box autocomplete-search-field">
<input name="q"
type="text"
class="mdc-text-field__input search-input-js aa-input-search"
placeholder="Search for players and videos ..."
aria-label="Full-Width Text Field"
autofocus>
</div>
</form>
</div>
</header>
The problem I have is that the dropdown menu is not visible on small screens for some reason and on bigger screens it is. This is the scss/css:
.algolia-autocomplete {
display: flex!important;
flex: auto!important;
height: 100%;
}
.aa-dropdown-menu {
position: relative;
top: -6px;
border-radius: 3px;
margin: 6px 0 0;
padding: 0;
text-align: left;
height: auto;
position: relative;
background: $white;
border: 1px solid #ccc;
width: 100%;
left: 0 !important;
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1);
}
.aa-dropdown-menu .aa-suggestions {
position: relative;
z-index: 1000;
}
.aa-dropdown-menu [class^="aa-dataset-"] {
position: relative;
border: 0;
border-radius: 3px;
overflow: auto;
padding: 0;
color: #3c3e42;
font-weight: 500;
}
.aa-dropdown-menu * {
box-sizing: border-box;
}
.aa-suggestion {
display: block;
width: 100%;
height: 72px;
clear: both;
.mdc-list-item {
height: 72px;
}
}
.aa-suggestion span {
white-space: nowrap !important;
text-overflow: ellipsis;
overflow: hidden;
display: block;
float: left;
line-height: 1em;
width: calc(100% - 30px);
}
.aa-suggestion.aa-cursor {
background-color: transparent;
}
.aa-suggestion em {
color: #00bcd4;
font-weight: 700;
}
.aa-suggestion img {
float: left;
height: 44px;
width: 44px;
margin-right: 6px;
}
.aa-suggestion a {
color: #3c3e42;
}
.aa-suggestions-category {
font-weight: 700;
color: #3c3e42;
border-bottom: 1px solid rgba(102, 105, 105, 0.17);
}
.powered-by-algolia {
padding-left: 15px;
border-top: 1px solid rgba(102, 105, 105, 0.17);
display: flex;
align-items: center;
height: 30px;
}
.aa-input-container {
display: inline-block;
position: relative; }
.aa-input-search {
width: 100%;
height: 30px;
padding: 12px 28px 12px 12px;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none; }
.aa-input-search::-webkit-search-decoration,
.aa-input-search::-webkit-search-cancel-button,
.aa-input-search::-webkit-search-results-button,
.aa-input-search::-webkit-search-results-decoration {
display: none;
}
.media {
margin: 10px 0;
}
.media-body {
p {
margin: 0;
}
}
.toolbar--custom {
color: $white;
.mdc-toolbar__row {
min-height: 56px;
}
form, .autocomplete-search-field {
width: 100%;
}
.mdc-text-field--box:not(.mdc-text-field--upgraded) {
height: 36px;
}
.mdc-text-field--box {
overflow: visible;
margin: auto;
.mdc-text-field__icon {
bottom: 8px;
font-size: 22px;
}
}
.mdc-text-field--box:after,
.mdc-text-field--box:before {
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#search-input-open {
display: none;
}
#media only screen and (max-width: 782px) {
#search-input-open {
display: block;
}
.search-field-desktop {
display: none;
}
}
}
.search-field-phone {
clip-path: circle(0%);
visibility: hidden;
.mdc-text-field {
clip-path: circle(0%);
}
}
#mixin search-animated-open {
-webkit-animation: open 0.3s forwards;
animation: open 0.3s forwards;
animation-timing-function: $mdc-animation-standard-curve-timing-function;
}
#mixin search-animated-close {
-webkit-animation: close 0.3s forwards;
animation: close 0.3s forwards;
animation-timing-function: $mdc-animation-standard-curve-timing-function;
}
.search-field-phone-open, {
visibility: visible;
#include search-animated-open;
.mdc-text-field {
#include search-animated-open;
}
}
.search-field-phone-close, {
#include search-animated-close;
.mdc-text-field {
#include search-animated-close;
}
}
#keyframes open {
from {
clip-path: circle(0 at calc(100% - 68px) 50%);
}
to {
clip-path: circle(150% at calc(100% - 68px) 50%);
}
}
#keyframes close {
from {
clip-path: circle(150% at calc(100% - 68px) 50%);
}
to {
clip-path: circle(0 at calc(100% - 68px) 50%);
visibility: hidden;
}
}
The layout of the whole page looks like this:
<div id="app">
#include('layouts.partials.sidebar')
#include('layouts.partials.navigation')
<div class="page-content">
#yield('content')
</div>
</div>
Where the navigation partial is the file with headers shown above. This is the sidebar partial:
<aside class="mdc-drawer mdc-drawer--temporary mdc-typography">
<nav class="mdc-drawer__drawer">
<header class="mdc-drawer__header">
<div class="mdc-drawer__header-content">
Header here
</div>
</header>
<nav id="icon-with-text-demo" class="mdc-drawer__content mdc-list">
<a class="mdc-list-item mdc-list-item--activated" href="#">
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">inbox</i>Inbox
</a>
<a class="mdc-list-item" href="#">
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">star</i>Star
</a>
</nav>
</nav>
</aside>
This is the css for the page:
body {
margin: 0;
}
#app {
display: flex;
}
.page-content {
display: inline-flex;
flex-direction: column;
flex-grow: 1;
height: 100%;
box-sizing: border-box;
}
I am not sure what is causing this behaviour, why is the dropdown menu for bigger screens visible, and the one for smaller screens not?
Update
I have noticed that when I have opened search input on small screens, if I remove the search-field-phone-open then the dropdown menu is visible, I am not sure what is in that class causing that the dropdown is not visible?
.search-field-phone-open, {
visibility: visible;
#include search-animated-open;
.mdc-text-field {
#include search-animated-open;
}
}
I am not sure I understood what you need but check the snippet below:
var client = algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76');
var index = client.initIndex('contacts');
$('.input-search').autocomplete({ hint: false }, [
{
source: function(searchBar, cb) {
index.search(searchBar, { hitsPerPage: 5 }, function(error, content) {
if (error) {
cb([]);
return;
}
cb(content.hits, content);
});
},
displayKey: 'name',
templates: {
suggestion: function(suggestion) {
return suggestion._highlightResult.name.value;
}
}
}
]);
.algolia-autocomplete {
display: flex!important;
flex: auto!important;
height: 100%;
}
.aa-dropdown-menu {
position: relative;
top: -6px;
border-radius: 3px;
margin: 6px 0 0;
padding: 0;
text-align: left;
height: auto;
position: relative;
background: $white;
border: 1px solid #ccc;
width: 100%;
left: 0 !important;
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1);
}
.aa-dropdown-menu:before {
position: absolute;
content: '';
width: 14px;
height: 14px;
background: #fff;
z-index: 0;
top: -7px;
border-top: 1px solid #D9D9D9;
border-right: 1px solid #D9D9D9;
transform: rotate(-45deg);
border-radius: 2px;
z-index: 999;
display: block;
left: 24px;
}
.aa-dropdown-menu .aa-suggestions {
position: relative;
z-index: 1000;
}
.aa-dropdown-menu [class^="aa-dataset-"] {
position: relative;
border: 0;
border-radius: 3px;
overflow: auto;
padding: 8px 8px 8px;
color: #3c3e42;
font-weight: 500;
}
.aa-dropdown-menu * {
box-sizing: border-box;
}
.aa-suggestion {
padding: 0 4px 0;
display: block;
width: 100%;
height: 38px;
clear: both;
}
.aa-suggestion span {
white-space: nowrap !important;
text-overflow: ellipsis;
overflow: hidden;
display: block;
float: left;
line-height: 1em;
width: calc(100% - 30px);
}
.aa-suggestion.aa-cursor {
background-color: transparent;
}
.aa-suggestion em {
color: #00bcd4;
font-weight: 700;
}
.aa-suggestion img {
float: left;
height: 44px;
width: 44px;
margin-right: 6px;
}
.aa-suggestion a {
color: #3c3e42;
}
.aa-suggestions-category {
font-weight: 700;
color: #3c3e42;
border-bottom: 1px solid rgba(102, 105, 105, 0.17);
}
.mdl-textfield {
margin: -20px !important;
}
/* fallback */
#font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialicons/v36/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-moz-font-feature-settings: 'liga';
-moz-osx-font-smoothing: grayscale;
}
<link href="https://storage.googleapis.com/code.getmdl.io/1.0.1/material.teal-red.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/material-components-web#0.8.0/dist/material-components-web.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
<script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.jquery.min.js"></script>
<script src="https://storage.googleapis.com/code.getmdl.io/1.0.1/material.min.js"></script>
<script src="https://unpkg.com/material-components-web#0.8.0/dist/material-components-web.min.js"></script>
<header class="mdc-toolbar">
<div class="mdc-toolbar__row">
<section class="mdc-toolbar__section mdc-toolbar__section--align-start">
menu
<span class="mdc-toolbar__title">Title</span>
</section>
<section class="mdc-toolbar__section">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable">
<label class="mdl-button mdl-js-button mdl-button--icon" for="site-search">
<i class="material-icons">search</i>
</label>
<div class="mdl-textfield__expandable-holder">
<input class="mdl-textfield__input input-search" name="searchBar" type="search" id="site-search" />
<label class="mdl-textfield__label" for="site-search">Search</label>
</div>
</div>
</section>
<section class="mdc-toolbar__section mdc-toolbar__section--align-end">
Custom icon
</section>
</div>
</header>
Hope this helps you.
References
I referred to mdc-toolbar available on GitHub.