I'm trying to stack the on top of each other vertically but they are overlapping for some reason and not sure if it has to do with the positioning. I'm not very good at CSS. Also, is there an easier way to align the datetime span to the right side instead of using padding-left: 1140px? Thank you
<div class="content-box">
<span class="name">John Doe</span>
<span class="datetime">May 2022</span><br><br>
<span class="content">Lorem ipsum</span>
</div>
<div class="content-box">
<span class="name">Jane Doe</span>
<span class="datetime">June 2022</span><br><br>
<span class="content">Lorem ipsum</span>
</div>
.content-box {
justify-content: center;
top: 600px;
position: absolute;
width: 75%;
border: none;
outline: none;
font-family: 'Roboto Mono', monospace;
font-size: 18px;
transform: translate(0);
background-image: linear-gradient(45deg, #4568DC, #B06AB3);
padding: 20px 40px;
border-radius: 5px;
box-shadow: 0 22px 44px rgba(128, 128, 128, 0.1);
transition: box-shadow .25s;
padding: 60px;
}
.content-box .name {
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: linear-gradient(45deg, #4568DC, #B06AB3);
font-size: 30px;
}
.content-box .content {
color: #4568DC;
font-size: 20px;
}
.content-box .datetime {
padding-left: 1140px;
color: black;
font-size: 18px;
}
.content-box .content {
color: #4568DC;
font-size: 20px;
}
.content-box:after {
content: '';
border-radius: 4px;
position: absolute;
margin: 1px;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: -1;
background: white;
}
.content-box:hover {
background-image: linear-gradient(-45deg, #00FFFF, #ff1a1a);
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
transition: .5s;
}
.content-box:hover .name {
background-image: linear-gradient(-45deg, #4568DC, #B06AB3);
}
The problem here is that both div has content-box class; this class applies position: absolute; , which is the main cause of overlapping. Removing this css property you should be able to se both div.
Regarding date time span you could change the class .content-box .datetime { color: black; font-size: 18px; } (you have to remove the padding)
And add the following properties to .content-box class to display datetime correctly without padding:
display: flex;
flex-flow: column;
Related
So I decided to do my portfolio website on my own, which turned out to work pretty ok so far. The only problem is that I can't seem to make it display properly on mobile view. That's even though I've made all the pertinent changes on the css with "#media screen"
Can somebody take a look and tell me why it's doing what it's doing?
To see the problem, go to https://er-sc.com/HTML/image_making.html
on mobile view
In the proper way the image shouldn't cover the "about" button.
Also if you notice anything I could correct to make the website better, let me know.
Looking forward to the community's feedback and suggestions.
Best,
Ellie
Here's my HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>ERSC Image Making</title>
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
<link href="../CSS/styles.css" rel="stylesheet" type="text/css">
</head>
<body id="bigwrapper">
<div class="topleft">
<a class="logoButton" href="https://www.er-sc.com/">E</a>
</div>
<div class="bottomleft">
<a class="logoButton" href="https://www.er-sc.com/">S</a>
</div>
<div class="topright">
<a class="logoButton" href="https://www.er-sc.com/">R</a>
</div>
<div class="bottomright">
<a class="logoButton" href="https://www.er-sc.com/">C</a>
</div>
<div class="bottomcenterLinks">
ABOUT
</div>
<div class="projectWrapper">
<div class="oneProject">
<div class="text">Happy Dancer, 2022</div>
<img src="/images/image-making/22-happy-dancer_k.jpg" alt="figure jumping">
</div>
<div class="oneProject">
<div class="text">Relief, 2022</div>
<img src="/images/image-making/22-0127_1__0020_Ebene-21-Wiederhergestellt_k.jpg" alt="3D extrusion of a scribble with plaster texture">
</div>
<div class="oneProject">
<div class="text">Didi, 2021</div>
<img src="/images/image-making/21-1210didi_k.jpg">
</div>
<div class="oneProject">
<div class="text">Dancing Flowers pt I, 2021</div>
<img src="/images/image-making/21-IG1_k.jpg">
</div>
<div class="oneProject">
<div class="text">Dancing Flowers pt II, 2021</div>
<img src="/images/image-making/21-IG2_k.jpg">
</div>
<div class="oneProject">
<div class="text">Sad Clown, 2021</div>
<img src="/images/image-making/21-200126_3D_1_k.jpg">
</div>
<div class="oneProject">
<div class="text">Alpine Anime (fictitious festival poster for Livia Rita), 2020</div>
<img src="/images/image-making/20-AlpineAnime_k.jpg">
</div>
<div class="oneProject">
<div class="text">Europa Endlos, 2019</div>
<img src="/images/image-making/19-europaendlos-scan_k.jpg">
</div>
<div class="oneProject">
<div class="text">Ascension, 2018</div>
<img src="/images/image-making/18-plakat_klein_ersc_k.jpg">
</div>
<div class="oneProject">
<div class="text">Seoul Impressions 1/4, 2018</div>
<img src="/images/image-making/18-1_k.jpg">
</div>
<div class="oneProject">
<div class="text">Seoul Impressions 2/4, 2018</div>
<img src="/images/image-making/18-7_k.jpg">
</div>
<div class="oneProject">
<div class="text">Seoul Impressions 3/4, 2018</div>
<img src="/images/image-making/18-9_k.jpg">
</div>
<div class="oneProject">
<div class="text">Seoul Impressions 4/4, 2018</div>
<img src="/images/image-making/18-10_k.jpg">
</div>
</div>
</body>
</html>
And here's my CSS
html,
#index {
height: 100%;
width: 100%;
background: radial-gradient(circle, hsla(295, 79%, 24%, 1) 0%, hsla(71, 66%, 78%, 1) 40%, hsla(318, 76%, 81%, 1) 74%, hsla(202, 27%, 45%, 1) 100%););
color: #551A8B;
font-family: sans-serif;
font-size: 1em;
background-attachment: fixed;
display: flex;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
}
#bigwrapper{
height: 100%;
width: 100%;
background: radial-gradient(circle, hsla(295, 79%, 24%, 1) 0%, hsla(71, 66%, 78%, 1) 40%, hsla(318, 76%, 81%, 1) 74%, hsla(202, 27%, 45%, 1) 100%););
color: #551A8B;
font-family: sans-serif;
font-size: 1em;
background-attachment: fixed;
display: flex;
display: -webkit-flex;
display: flex;
-webkit-align-items: top !important;
align-items: top !important;
-webkit-justify-content: center;
justify-content: center;
}
#font-face {
font-family: 'FT88-Italic';
font-style: normal;
font-weight: 400;
src: url('/fonts/FT88-Italic') format('woff2');
}
p {
font-family: 'FT88-Italic', sans-serif;
}
h1 {
font-family: 'FT88-Italic', sans-serif;
font-size: 2vw;
font-weight: normal;
}
.socials{
font-size: 2vw;
}
a {
text-decoration: none;
color: #551A8B;
font-family: sans-serif;
}
mark {
background-color: rgba(85, 26, 139, 1);
color: white;
border-radius: 0.3em;
}
#wrapper {
height: 80%;
width: 80%;
padding: 0em;
}
.extraBG {
z-index: 1000;
height: 100vh;
width: 50vw;
position: fixed;
background-color: red;
right: 0%;
top:0%
background-repeat: repeat;
background-position: top right;
background-attachment: fixed;
}
.topleft{
position: fixed;
top: 3%;
left: 3%;
z-index: 100;
}
.bottomleft{
position: fixed;
bottom: 3%;
left: 3%;
z-index: 100;
}
.topright{
position: fixed;
top: 3%;
right: 3%;
z-index: 100;
}
.bottomright{
position: fixed;
bottom: 3%;
right: 3%;
z-index: 100;
}
.bottomcenterLinks{
position: fixed;
bottom: 5%;
text-align: center;
text-decoration: none;
vertical-align: middle;
display: table-cell;
font-family: "FT88-Italic", sans-serif;
font-size: 3vh;
color: floralwhite;
}
.bottomcenterLinks a {
color: floralwhite;
text-shadow: 0px 0px 0.25em #551A8B;
}
.bottomcenterLinks a:hover {
color: floralwhite;
text-shadow: 0px 0px 0.15em floralwhite;
transition: 0.6s ease;
}
.bottomcenterLinks a:active {
color: floralwhite;
text-shadow: 0px 0px 0.15em floralwhite;
transition: 0.6s ease;
}
.bottomSmall{
text-align: center;
font-size: 0.8em;
align-self: flex-end;
}
.logoButton {
background-color: floralwhite;
font-family: sans-serif;
width: 8vh;
height: 8vh;
text-align: center;
vertical-align: middle;
text-decoration: none;
display: table-cell;
font-size: 3vh;
cursor: pointer;
border-radius: 100%;
z-index: 999;
position: relative;
box-shadow: inset 6px -6px 8px 1px rgba(224, 211, 185, 0.8), inset -16px 14px 10px 5px rgba(255, 255, 255, 0.8);
transition: 0.25s ease;
text-transform: uppercase;
z-index: 999;
filter: blur(0.05em);
-webkit-filter: blur(0.05em);
}
.logoButton:hover, .logoButton:active{
box-shadow: inset 6px -6px 0.8em 1px rgba(255, 255, 255, 0.8), inset -16px 18px 0.8em 0.05em rgba(224, 211, 185, 0.8);
filter: blur(0em);
-webkit-filter: blur(0em);
}
.centeredBox{
margin: auto;
border-radius: 5em;
background: floralwhite;
text-align: center;
font-size: 1.2em;
padding: 0.6em;
vertical-align: middle;
margin: auto;
height: 90%;
display: flex;
flex-wrap : nowrap;
flex-direction: column;
justify-content: center;
align-items : stretch;
flex-direction: column;
align-content : space-between;
/* box-shadow: inset 6px -6px 0.5em 1px rgba(224, 211, 185, 0.5), inset -16px 14px 10px 5px rgba(255, 255, 255, 0.8);
transition: 0.25s ease;
*/
}
.centeredBox small{
text-align: center;
align-content : flex-end;
}
.part1, .part2, .part3, .part4, .part5{
border-radius: 100em;
background: floralwhite;
text-align: center;
box-shadow: inset 6px -6px 0.5em 1px rgba(224, 211, 185, 0.5), inset -16px 14px 10px 5px rgba(255, 255, 255, 0.8);
transition: 0.25s ease;
vertical-align: middle;
filter: blur(0.1em);
-webkit-filter: blur(0.1em);
}
.part1:hover, .part2:hover, .part3:hover, .part4:hover, .part5:hover, .part5:active {
box-shadow: inset -21px 26px 50px -51px #FFFAF0, inset 10px -13px 50px -31px #FFFAF0, inset 34px -36px 50px 35px rgba(255, 255, 255, 0.6), inset -31px 37px 50px 32px rgba(224, 211, 185, 0.25);
filter: blur(0em);
-webkit-filter: blur(0em);
}
/*
.centeredBox, .slideshowBox{
width:100%;
height: 100%;
float: left;
}
*/
.centeredBox p {
position: relative;
padding: 1em;
height:20px;
top: 5%;
transform: translateY(-50%);
text-align: center;
vertical-align: middle;
}
.part1 {
width:50%;
height: 30%;
float: left;
}
.part1 p{
position: relative;
height:20px;
top: 40%;
transform: translateY(-50%);
}
.part2 {
width:50%;
height: 30%;
float: left;
}
.part2 p{
position: relative;
height:20px;
top: 40%;
transform: translateY(-50%);
}
.part3 {
width:50%;
height: 30%;
float: left;
}
.part3 p{
position: relative;
height:20px;
top: 40%;
transform: translateY(-50%);
}
.part4 {
width:50%;
height: 30%;
float: left;
}
.part4 p{
position: relative;
height:20px;
top: 40%;
transform: translateY(-50%);
}
.part5 {
width:65%;
height: 33%;
margin: auto;
display:flex;
justify-content: center;
vertical-align: middle;
}
.part5 p {
position: relative;
text-align: center;
vertical-align: middle;
font-size: 6vw;
margin: auto;
/* transform: translateY(-50%); */
}
.selected{
color: #FFFAF0;
filter: blur(0.05em);
}
.slideshowBox{
border-radius: 4em;
background: floralwhite;
text-align: center;
font-size: 1.2em;
filter: drop-shadow(10px,10px,orange);
}
.slideshow-container{
height: 100%;
width: 90%;
padding-top: 0em;
padding-bottom: 0em;
border-radius: 4em;
margin: auto;
text-align: center;
vertical-align: middle;
}
.mySlides {
display: none;
text-align: center;
vertical-align: middle;
}
.projectWrapper {
z-index: 10;
display: inline-block;
text-align: center;
vertical-align: top;
margin-top: 5em;
/*overflow-y: scroll;
scroll-snap-type: y mandatory;*/
padding-bottom: 7.5em;
}
.oneProject {
padding-bottom: 7.5em;
/*scroll-snap-align: start;
scroll-snap-stop: always;*/
}
img {
/* vertical-align: middle; */
border-radius: 1em;
max-height: 75vh;
max-width: 75vw;
margin: auto;
display: block;
text-align: center;
}
.imgSmall {
max-height: 70vh;
}
/* Next & previous buttons */
.prev {
vertical-align: middle;
cursor: pointer;
position: absolute;
top: 10%;
left: 0em;
width: 40%;
padding-top: 17em;
padding-bottom: 17em;
color: rgba(0, 0, 0, 0);
font-size: 1.2em;
transition: 0.6s ease;
user-select: none;
}
/* Position the "next button" to the right */
.next {
vertical-align: middle;
cursor: pointer;
position: absolute;
top: 10%;
right: 0em;
width: 40%;
padding-top: 17em;
padding-bottom: 17em;
color: rgba(0, 0, 0, 0);
font-size: 1.2em;
transition: 0.6s ease;
user-select: none;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
color: rgba(0, 0, 0, 0);
}
/* Caption text */
.text {
font-size: 1.2em;
position: relative;
margin: auto;
display: block;
text-align: center;
padding-bottom: 0.5em;
font-family: sans-serif;
}
/* Fading animation */
.fade {
animation-name: fade;
animation-duration: 1.5s;
}
#keyframes fade {
from {opacity: .6}
to {opacity: 1}
}
#media screen and (max-width: 1200px) {
h1 {
font-size: 4vw;
}
.socials {
font-size: 3vw;
}
.bottomcenterLinks {
font-size: 3vh;
}
.selected {
font-size: 3vh;
}
.centeredBox small{
font-size: 3vw;
}
}
#media screen and (max-width: 800px) {
.oneProject {
margin-bottom: 40%;
}
.projectWrapper {
margin-top: 30%;
}
.logoButton {
filter: blur(0.03em);
-webkit-filter: blur(0.03em);
}
.part5 {
filter: blur(0.06em);
-webkit-filter: blur(0.06em);
}
}
so, I think that it's because you added z-index directly to the about link tag in your css. Try adding z-index to the link wrapper div, in this case "bottomcenterLinks".
.bottomcenterLinks{
position: fixed;
bottom: 5%;
text-align: center;
text-decoration: none;
vertical-align: middle;
display: table-cell;
font-family: "FT88-Italic", sans-serif;
font-size: 3vh;
color: floralwhite;
z-index: 100;
}
now, a feedback for your website design:
it's a pretty innovative design but thinking in user experience i would change the buttons because when we first get into the page we can't understand the purpose of the buttons because they don't have proper names, I mean, self explanatory names. i understand that you wanted to use your name first letters but for the purpose of a portfolio or even another type of website you're building, I think is better building something that will literaly guide the user through the website. think about it!
also, this about link that you're trying to make appear, i think it would be better if you style it like the buttons with your name first letters, it would make it stand out better. oh and i think that instead of having only about, you could have about me written there because when I first saw it I couldn't understand what that about link is supposed to be I mean, is about what, the projects, you, the page?
last but not less important, the blur in your buttons in a user perspective seems like the content is not in a good quality. i don't understand what you wanted it to look like but if you like it that way, no need to change, except if you want to prioritize user exp! besides this, i wouldn't fix anything else, i really enjoyed your design, is cute, innovative, simple, you're doing well!
sry about the big comment tho, but i hope you understand my feedback!
I just need to style two-tone color background like this.
I tried and successfully did using linear gradient
background: linear-gradient(172deg, #ECB034 50%, #BE883C 50%);
But it has a problem when resizing web page. It just not well aligned to its corners. Showing weirdly. Like this
is there any way to did this?
.cta{
padding: 60px 0;
background: linear-gradient(172deg, #ECB034 50%, #BE883C 50%);
text-align:center;
}
.cta h3{
font-size: 58px;
margin-bottom: 30px;
font-weight: 700;
}
.cta a{
padding: 16px 49px;
border: 2px solid #000;
color: inherit;
font-size: 20px;
text-transform: uppercase;
display: inline-block;
font-weight: 500;
}
<div class="cta text-center">
<div class="container">
<h3>Let’s talk about your project.</h3>
Get Started >
</div>
</div>
This is a very simple fix with an SVG (as I mentioned in the comments) you simply need to add preserveAspectRatio="none" to the SVG tag and run it through a URL encoder. This one will even generate the CSS for you which is quite nice.
.cta{
padding: 60px 0;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='100%25' width='100%25' preserveAspectRatio='none' viewBox='0 0 10 10'%3E%3Crect width='10' height='10' fill='%23ECB034' /%3E%3Cpath d='m0 10 h10 v-10' fill='%23BE883C' /%3E%3C/svg%3E");
text-align:center;
}
.cta h3{
font-size: 58px;
margin-bottom: 30px;
font-weight: 700;
}
.cta a{
padding: 16px 49px;
border: 2px solid #000;
color: inherit;
font-size: 20px;
text-transform: uppercase;
display: inline-block;
font-weight: 500;
}
<div class="cta text-center">
<div class="container">
<h3>Let’s talk about your project.</h3>
Get Started >
</div>
</div>
You don't need anything complex. Simply change the angle with to bottom right
.cta{
padding: 60px 0;
background: linear-gradient(to bottom right, #ECB034 50%, #BE883C 50%);
text-align:center;
}
.cta h3{
font-size: 58px;
margin-bottom: 30px;
font-weight: 700;
}
.cta a{
padding: 16px 49px;
border: 2px solid #000;
color: inherit;
font-size: 20px;
text-transform: uppercase;
display: inline-block;
font-weight: 500;
}
<div class="cta text-center">
<div class="container">
<h3>Let’s talk about your project.</h3>
Get Started >
</div>
</div>
You can use pseudo and clip-path combination.
.box{
position:relative;
background-color: #ecae20;
text-align:center;
margin: 30px;
padding: 30px;
z-index:1;
}
.box .content{
position:relative;
z-index:3;
}
.box:before {
content: "";
position:absolute;
left:0;
bottom:0;
width: 100%;
height: 100%;
background-color: #BE883C;
clip-path: polygon(0 99%, 100% 0, 100% 99%, 0 100%);
opacity: 0.7;
z-index:2;
}
<div class="box">
<div class="content">
<p> Let's talk about your project </p>
<button> GET STARTED > </button>
</div>
</div>
As the angle needed changes with the aspect ratio it is not possible to do this with linear-gradient without some recalculation on every resize. (This is incorrect, see better suggestion from #temaniAfif using to bottom left etc.)
However, it is possible to create a triangle with its hypoteneuse being a diagonal by using clip-path and a polygon.
There is no need to inline an SVG if you put the two colors as backgrounds to the before and after pseudo elements, the after also having a clip-path.
.cta {
padding: 60px 0;
text-align: center;
position: relative;
}
.cta::before,
.cta::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.cta::before {
background-color: #ECB034;
}
.cta::after {
background-color: #BE883C;
clip-path: polygon(0 100%, 100% 0, 100% 100%);
}
.cta h3 {
font-size: 58px;
margin-bottom: 30px;
font-weight: 700;
}
.cta a {
padding: 16px 49px;
border: 2px solid #000;
color: inherit;
font-size: 20px;
text-transform: uppercase;
display: inline-block;
font-weight: 500;
}
<div class="cta text-center">
<div class="container">
<h3>Let’s talk about your project.</h3>
Get Started >
</div>
</div>
You can use pseudo element for the same.
#import "https://cdn.jsdelivr.net/gh/KunalTanwar/normalize/css/normalize.inter.min.css";
body {
height: 100%;
display: grid;
place-items: center;
}
.container {
--container-width: 400px;
--container-height: 200px;
width: 100%;
background-color: #ecb034;
height: var(--container-height);
max-width: var(--container-width);
}
.container::after {
content: "";
position: absolute;
width: 0;
height: 0;
user-select: none;
pointer-events: none;
inset: auto 0 0 auto;
border-bottom: var(--container-height) solid #be883c;
border-left: var(--container-width) solid transparent;
}
<div class="container"></div>
Make sure to keep border-left-width and width of the container same. And same for height.
I want to make the color of div darker on hover
I tried decrease the brightness using filter but this affect the text too
:root{
--Dark-cyan: hsl(158, 36%, 37%);
}
#submit{
background: var(--Dark-cyan);
text-align: center;
vertical-align: middle;
color: white;
font-weight: 700;
font-size: 14px;
width: fit-content;
height: fit-content;
padding: 15px 60px;
border-radius: 15px;
}
#submit:hover{
filter: brightness(50%);
}
<div id="submit"> Add to Cart</div>
this is the result that I want:
off hover
on hover
You can use backdrop-filter instead of filter :)
"Because it applies to everything behind the element, to see the effect you must make the element or its background at least partially transparent".
Unfortunately for firefox, this requires at this time: User must explicitly enable the feature
:root {
--Dark-cyan: hsl(158, 36%, 37%, 0.9);
}
#submit {
background: var(--Dark-cyan);
text-align: center;
vertical-align: middle;
color: white;
font-weight: 700;
font-size: 14px;
width: fit-content;
height: fit-content;
padding: 15px 60px;
border-radius: 15px;
}
#submit:hover {
backdrop-filter: brightness(50%);
}
<div id="submit"> Add to Cart</div>
You could use box-shadow: inset with a large spread-radius
it doesn't affect the text color
:root{
--Dark-cyan: hsl(158, 36%, 37%);
}
#submit{
background: var(--Dark-cyan);
text-align: center;
vertical-align: middle;
color: white;
font-weight: 700;
font-size: 14px;
width: fit-content;
height: fit-content;
padding: 15px 60px;
border-radius: 15px;
}
#submit:hover{
box-shadow: inset 0 0 0 /*spread-radius:*/ 100px #33333377;
}
<div id="submit"> Add to Cart</div>
Try this:
You can try reducing the alpha property from rgba()
Try like this:
.your-css-class:hover {
background: rgba(0, 0, 0, 0.25);
}
This can be done using the pseudo ::before and ::afer and some opacity on hover. Take a look at the snippet
:root { --Dark-cyan: hsl(158, 36%, 37%, 0.9) }
.btn, .btn::before, .btn::after { border-radius: 15px }
.btn {
color: white;
cursor: pointer;
display: inline-block;
font-size: 14px; font-weight: 700;
height: fit-content; width: fit-content;
padding: 15px 60px;
position: relative;
}
.btn::before, .btn::after {
content: "";
display: block;
position: absolute;
inset: 0;
z-index: -1
}
.btn::before { background-color: black }
.btn::after { transition: opacity 360ms 0ms ease-in-out }
.btn:hover::after { opacity: 0.6 }
#submit::after { background-color: var(--Dark-cyan) }
#remove::after { background-color: red }
<div class="btn" id="submit">Add to Cart</div>
<div class="btn" id="remove">Remove from Cart</div>
When putting a div behind another div the text in bot div elements is aligned.
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-size: 24px;
font-family: Verdana;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
z-index: 2;
position: relative;
}
.underlayer {
top: -48px;
z-index: 1;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
}
<div class="wrapper">
<div type="text" class="box top">20-123</div>
<div class="box underlayer">20-123-20</div>
</div>
When the div with class top is replaced with an input, the text is 1px off, though the border is still aligned correctly.
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-family: Verdana;
font-size: 24px;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
z-index: 2;
position: relative;
}
.underlayer {
top: -48px;
z-index: 1;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
}
<div class="wrapper">
<input type="text" value="20-123" class="box top">
<div class="box underlayer">20-123-20</div>
</div>
I can't put my head around it. Somebody here to explain it and suggest how to resolve this ?
This happens because of how inputs are handled. The textfield inside an input-element is streched to fit the box size. In this case 34px. So the fix is to increase the div's line-height to match the 34px of the input.
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-family: Verdana!important;
font-size: 24px;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
z-index: 2;
position: relative;
}
.underlayer {
top: -48px;
line-height: 34px;
z-index: 1;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
}
<div class="wrapper">
<input type="text" value="20-123" class="box top">
<div class="box underlayer">20-123-20</div>
</div>
You have a problem with your fonts.
You have one font for the underlayer and one for the other.
I also add a font-size and hide your second box so you can move the top position of your underlayer to match with the text on top.
It's probably not the best way to do it, but it works.
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-size: 24px;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
font-family: sans-serif;
z-index: 2;
position: relative;
}
.underlayer {
font-family: sans-serif;
font-size: 24px;
top: -44px;
left: 1px;
z-index: 1;
border: 0px solid #cccccc;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
}
<div class="wrapper">
<input type="text" value="20-123" class="box top">
<div class="box underlayer">20-123-20</div>
</div>
How to resolve it is here:
.wrapper {
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
padding-right: 20px;
}
.box {
height: 34px;
width: 130px;
padding: 6px 12px;
font-size: 24px;
color: #555555;
background: rgba(255, 255, 255, 0) none;
border: 1px solid #cccccc;
border-radius: 4px;
}
.top {
z-index: 2;
position: relative;
}
.underlayer {
top: -48px;
z-index: 1;
position: relative;
background: rgba(255, 255, 255, 1);
color: #c8c8c8;
margin:0;
display: block;
tabindex: -1;
}
<div class="wrapper">
<input type="text" value="20-123" class="box top">
<input class="box underlayer" value="20-123-20">
</div>
You change underlayer from div to input. It changes second div's font to the one used by inputs. Because underlayer has lower z-index, it will never be selected by user, no it doesn't create any danger. You also set second input's display to block.
Unfortunately, I don't know why it originally happened, so I can't explain it.
I am having trouble vertically aligning the 's text inside a div.
This is what I have. I need to center "Next" inside the blue box:
#import url(http://fonts.googleapis.com/css?family=Muli);
/*Makes the little side arrow*/
.open {
position: fixed;
width: 100px;
height: 40px;
left: 50%;
top: -1000px;
margin-left: -80px;
margin-top: -30px;
border: 1px solid #ccc;
background-color: #fff;
border-radius: 6px;
padding: 10px 30px;
color: #444;
transition: all ease-out 0.6s;
}
.open:hover {
border: 1px solid #aaa;
box-shadow: 0 0 8px #ccc inset;
transition: all ease-out 0.6s;
}
.tutorial-box {
position: fixed;
width: 400px;
height: 238px;
top: 75px;
background-color: #F3F3F3;
border-radius: 6px;
box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.4);
}
.slider-turn p, .tutorial-box h1{
margin-left: 10px;
}
.tutorial-box:before {
content: '';
position: absolute;
left: -14px;
top: 28px;
border-style: solid;
border-width: 10px 14px 10px 0;
border-color: rgba(0, 0, 0, 0) #f3f3f3 rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
}
.tutorial-box p {
width: 350px;
font-size: 16px;
color: #a8aab2;
font-weight: 400;
line-height: 28px;
float: left;
margin: 0;
}
.tutorial-box .bottom {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
width: 100%;
bottom: 0;
position: absolute;
}
.tutorial-box .bottom .btn-2 {
flex: 3;
-webkit-flex: 3;
-ms-flex: 3;
width: 100%;
height: 54px;
background-color: #373942;
border-bottom-left-radius: 6px;
display: flex;
}
.tutorial-box .bottom span {
flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
line-height: 54px;
color: #fff;
margin-left: 25px;
font-size: 18px;
}
.next {
text-decoration: none;
display: inline-block;
vertical-align: middle;
text-align: center;
flex: 1;
background-color: #6cb5f3;
border: 0;
margin: 0;
padding: 0;
text-transform: uppercase;
color: #fff;
font-weight: bold;
border-bottom-right-radius: 6px;
cursor: pointer;
transition: all .3s;
}
.next:hover {
text-decoration: none;
background-color: #6BA5D6;
transition: all .3s;
}
.next:active {
text-decoration: none;
background-color: #5F8AAF;
}
.slider-tutorial-box {
width: 350px;
margin: 0 25px;
overflow: hidden;
}
.slider-turn {
width: 10000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- TUTORIAL -->
<div class="tutorial-box">
<h1>Welcome</h1>
<span class="close"></span>
<div class="slider-container">
<div class="slider-turn">
<p>
Here, under the Company tab, is where you will do most of the company managment.<br>
</p>
</div>
</div>
<div class="bottom">
<div class="btn-2">
<span>Step 2/?</span>
</div>
Next
</div>
</div>
Please let me know how I can center the text vertically to the center of the div.
Thank you very much. Let me know if I wasn't clear enough.
Seems like you already did that for .tutorial-box .bottom span so, do the same thing for .next
.next{
line-height: 54px;
}
the simplest and possibly most easy way would be to add the 'center' and '/center' tag before and after the text you want, and after each letter use '/br' to move to the next line. this will add some bulk, but would be considerably easier than other methods.
<center>
'letter'</br>'next letter'</br>'next letter'</br>
</center>
repeating the letter and break for all letters
alternatively, you could also add "div" tags around the "a" tag. you would have to modify the 'height' and 'width' to make it vertical for you. I would use px for this and not '%' or 'em'. add this to them:
<div style="height: /* modify this */100px; width: /* and this*/20px;">
Next
</div>
this may not be AS compatible cross platform though.
Like this:
.next {
position: relative;
top: 50%;
transform: translateY(-50%);
}
A nice trick that works both vertically and horizontally.