Grid Container will not take up the full vh - css

My Grid Container looks to be stuck inside of a "root" div when I inspect.
I'm wanting my middle row to take up all remaining height in the grid. Right now my grid is stuck to the top of the screen.
Here is my code:
*,
:root {
--dark: #12121f;
--dark-gray: #303133;
--light: #f7f8fc;
--accent: #380082;
--modal: #3949ab;
--sections: #1f85b4;
--text: #f5f5f5;
}
html {
height: 100%;
}
::after,
::before {
margin: 0;
padding: 0;
box-sizing: border-box;
}
p {
margin: 0;
}
code {
font-family: "Montserrat", source-code-pro, Menlo, Monaco, Consolas,
"Courier New", monospace;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: var(--dark-gray);
color: var(--white);
}
.grid-container {
height: 100%;
margin: 20px;
display: grid;
grid-gap: 8px;
grid-template-columns: [main-start] 1fr [content-start] 5fr [content-end main-end];
grid-template-rows: [main-start] 100px [content-start] auto [content-end] 100px [main-end];
align-content: center;
justify-content: center;
border: purple 1px solid;
}
.header-grid {
grid-column: main;
font-size: 3rem;
text-align: center;
font-family: "Montserrat";
font-weight: bold;
text-shadow: 0px 4px 4px rgba(122, 123, 126, 0.45);
background: white;
}
.menu-grid {
background: white;
padding: 20px;
text-align: center;
align-content: center;
padding-top: 50px;
padding-bottom: 30px ;
}
.about-grid {
grid-area: content;
justify-content: center;
background: white;
padding: 20px;
}
.email-grid {
grid-column: main;
display: flex;
justify-content: space-around;
background: white;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
and here is my react component:
import React from "react";
const Contact = () => {
document.title = "Contact";
return (
<>
<div className="grid-container">
<div className="header-grid">The WholeSale Group</div>
<div className="menu-grid">
<ul>
<li>HOME</li>
<li>ORDERS</li>
<li>INVENTORY</li>
<li>STATEMENTS</li>
</ul>
</div>
<div className="about-grid">
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Pariatur,
ut corporis. Voluptates quas, magni quisquam possimus id quam
cupiditate odio distinctio similique, atque fugit consequuntur
aperiam esse nihil voluptatum neque. Lorem, ipsum dolor sit amet
consectetur adipisicing elit. Pariatur, ut corporis. Voluptates
quas, magni quisquam possimus id quam cupiditate odio distinctio
similique, atque fugit consequuntur aperiam esse nihil voluptatum
neque.
</p>
</div>
<div className="email-grid">
<p>Sales: email#email.com</p>
<p>Support: email#email.com</p>
<p>Upline: email#email.com</p>
</div>
</div>
</>
);
};
export default Contact;
// TP-43
Here is a screenshot of my grid under inspection
Thanks in advance for any help!
I've tried setting root to 100% or 100vh and have also tried both options on html and body as well.
If I change the last value in my grid template rows to something like 700px; it stretches the whole view height. Likewise, if I change my content (middle) row value to the same, it stretches down further.
I put "auto" there so it would take up all remaining height of the page.
I also tried min-content with no luck.

Related

flex column and wrap will let flex-item overflow

A simple layout that I want to achieve with minimal html tags
Only <img> & <h1> & <p> and no other extra tags
flex + column + wrap
The first column has only one image
The second column contains the title and crossword
The width and height of the parent layer are fixed
The result is that part of the text will overflow
Only add width to <p> to prevent
Is there any way to automatically break text without adding width?
HTML
*{
margin: 0;
padding: 0;
}
.out{
width: 600px;
height: 200px;
border: 1px solid #ccc;
padding: 20px;
margin: 50px auto;
font-family: Verdana;
display: flex;
flex-direction: column;
flex-wrap: wrap;
}
img{
/* margin-bottom: 20px; */
margin-right: 20px;
}
p{
line-height: 1.6;
overflow-wrap: break-word;
}
<div class="out">
<img src="https://picsum.photos/id/230/200/200" alt="">
<h1>This is Title</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta iure iusto cupiditate sequi aperiam, nostrum optio ipsam dicta modi officiis eligendi vel. Dignissimos delectus exercitationem nemo. Enim id sed corrupti!</p>
</div>
Another solution as per your expecation:
* {
margin: 0;
padding: 0;
}
.out {
width: 600px;
height: 200px;
border: 1px solid #ccc;
padding: 20px;
margin: 50px auto;
font-family: Verdana;
display: flex;
}
img {
/* margin-bottom: 20px; */
margin-right: 20px;
}
p {
line-height: 1.6;
overflow-wrap: break-word;
margin-left: -200px;
margin-top: auto;
margin-bottom: auto;
}
h1 {
position: relative;
white-space: nowrap;
}
p::before {
content: "";
width: 100%;
}
<div class="out">
<img src="https://picsum.photos/id/230/200/200" alt="">
<h1>This is Title</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta iure iusto cupiditate sequi aperiam, nostrum optio ipsam dicta modi officiis eligendi vel. Dignissimos delectus exercitationem nemo. Enim id sed corrupti!</p>
</div>
Here is my solution
* {
font-family: 'poppins';
}
.card {
display: flex;
padding: 15px;
border: 1px solid #8f8f8f;
}
.content {
margin-left: 10px;
}
.content h6 {
margin-top: 0;
font-size: 32px;
margin-bottom: 5px;
}
<div class="card">
<img src="//via.placeholder.com/150">
<div class="content">
<h6>This is title</h6>
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
here, content here', making it look like readable English.</p>
</div>
</div>

Pseudo element is not scrollable when it has a transparent background

I have some text displaying in an ::after psuedo element that I would like to be scrollable. It works fine until I change the background of that element from:
background-color: rgb(0,0,0);
to:
background-color: rgba(0,0,0,0.5);
Is there a way to allow scrolling with a transparent background?
Here is the HTML with working and broken example:
<div class="wrapper">
<div class="column working">
<p>Working: text is scrolling properly.</p><br>
<div class="container">
<img src="https://source.unsplash.com/random/400x200" />
</div>
</div>
<div class="column broken">
<p>Broken: text is not scrolling.</p><br>
<div class="container">
<img src="https://source.unsplash.com/random/400x200" />
</div>
</div>
</div>
And the CSS to go with it:
* {
margin: 0;
padding: 0;
}
.wrapper {
display: flex;
}
.column {
padding: 1rem;
background: yellowgreen;
}
.container {
display: inline-block;
position: relative;
font-family: monaco;
}
.container::after {
content: "Dis iusto aliquid sollicitudin iaculis modi fugit, non irure quisquam molestiae arius laboris, eiusmod? Pulvinar eleifend volutpat, quae nunc magnam? Hac, nam? Dignissimos esse diamlorem dolore accusamus dolores, ipsa facilis ullam illo, fames ex? Maecenas tellus. Aspernatur eum malesuada, assumenda, hac, ultricies? Aliquet in, harum fugiat! Volutpat recusandae! Fames saepe fames corrupti.";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: inherit;
height: inherit;
padding: 1rem;
z-index: 10;
overflow-x: scroll;
cursor: pointer;
font-family: monaco;
line-height: 1.5em;
color: aqua;
}
.column.working .container::after {
background-color: rgb(0,0,0);
}
.column.broken .container::after {
background-color: rgba(0,0,0,0.5);
}
img {
display: block;
}
p {
font-family: monaco;
}
And here is the above code, in a CodePen
Thanks.
As suggested, this appears to be a browser bug that has since been fixed. Marking as resolved.

Background-Image behind Header Section with CSS Grid

i'm trying to recreate this template through the use of Grid. I can't figure how to create the background-image behind what i've already created
in my markup. Image what i'm after refrence image any tips?
check my website, what have i already done, i thought to use z-indexing, but it didn't worked.. also if i apply it to the body, it will stretch with the additional content after the header section.
*{
box-sizing: border-box;
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
font-family: 'Montserrat', sans-serif, arial;
}
a{
color: black;
}
body{
background-color: red;
margin: 0 auto;
width: 80%;
}
/* .background-image{
background-image: url(../img/bgheader.jpg);
background-repeat: no-repeat;
background-size: cover;
grid-column: 1 / -1;
grid-row: 1 / 4;
} */
#grid-container{
display: grid;
grid-template-columns: repeat(12,1fr);
grid-gap: 1rem;
}
header{
grid-column: 1 / 13;
display: grid;
grid-template-columns: 1fr 11fr;
grid-template-rows: 1fr 10fr 1fr 4fr;
margin-top: 5rem;
}
header ul{
display: flex;
justify-content: flex-end;
}
header ul li:nth-child(-n+3){
margin-right: 3rem;
}
header ul a{
text-transform: uppercase;
font-weight: 400;
color: white;
}
header a:hover{
color: grey;
}
.slogan{
grid-row: 2 / 3;
grid-column: 1 / 3;
justify-self: center;
align-self: center;
text-align: center;
}
.slogan h1{
font-size: 2.5rem;
color: white;
margin-bottom: 1rem;
text-transform: uppercase;
}
.more{
color: white;
}
.services{
color: #4a4747;
grid-row: 4 / 5;
grid-column: 1 / 3;
justify-self: center;
align-self: center;
text-align: center;
padding: 0 20rem;
}
.services h2{
margin-bottom: 1rem;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/style.css">
<title>Brackets Junior</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
</head>
<body>
<div id="grid-container">
<!-- Header Section -->
<header>
<img class="logo" src="img/logo.png" alt="logo">
<nav>
<ul>
<li>Home</li>
<li>Services</li>
<li>Portfolio</li>
<li>Blog</li>
</ul>
</nav>
<div class="slogan">
<h1>Always a step ahead go pro</h1>
Learn more..
</div>
<div class="services">
<h2> We provide the best services</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia voluptatum blanditiis expedita ducimus fugit rem, qui repellat, quos totam ipsa reprehenderit eum laboriosam maiores. Eum fugit provident error velit soluta, praesentium enim dolorum architecto, quis quisquam magnam! Sequi voluptas consequatur dolor asperiores rem eaque voluptatem necessitatibus laborum alias, omnis atque.</p>
</div>
</header>
</div>
</body>
</html>
Just apply your background to the header.
header{
grid-column: 1 / 13;
display: grid;
grid-template-columns: 1fr 11fr;
grid-template-rows: 1fr 10fr 1fr 4fr;
margin-top: 5rem;
background-image: url(../img/bgheader.jpg);
background-repeat: no-repeat;
background-size: cover;
}
I am not sure why your header includes your page contents, nor why you are placing the header grid inside the page grid. These things might be revisited.
write some text in header or li components and then apply min padding of 400px
or top and bottom padding of 200px. this will resolve your problem

CSS Flex Justify-content dont push elements to each corner

Hi I want to push 2 elements to each corner like what float actually do
so I give the parent display flex and justify-content, space between but it seems like theres margin left before the first element and margin right after the last element.
in this example the header is parent and h1 is the first element and nav is the last element.
I want h1 stick to the left and nav stick to the right with display flex.
HTML
<header>
<h1>Thermos</h1>
<nav>
<a href='#'>Add URL</a>
<a href='#'>Sign Up</a>
<a href='#'>Sign In</a>
</nav>
</header>
<main>
<section id='main'>
<div id='intro'>
<h1>Welcome</h1>
<p>Thermos is a simple social bookmarking site. Or actually, you can use it the way you want.</p>
</div>
<article>
<h2>Article section h2</h2>
<p>Qui ne magna delenit splendide, diam ullum regione vis no, an modo numquam eum. Ne ullum clita libris vel. In tantas graeci molestiae eam, ei sed aeterno aperiri fabulas. Quo eu quod dicta, nec sint expetenda eu. Aeque nobis verterem ea cum, sed no hinc salutandi consetetur. Volumus assueverit in qui, commodo nominavi ad pro.</p>
</article>
<article>
<h2>Article section h2</h2>
<p>Qui ne magna delenit splendide, diam ullum regione vis no, an modo numquam eum. Ne ullum clita libris vel. In tantas graeci molestiae eam, ei sed aeterno aperiri fabulas. Quo eu quod dicta, nec sint expetenda eu. Aeque nobis verterem ea cum, sed no hinc salutandi consetetur. Volumus assueverit in qui, commodo nominavi ad pro.</p>
</article>
</section>
<aside>
<h3>Aside</h3>
<p>Dico tantas definiebas eum ad, nostrum reprimique duo no. Ut pri causae ponderum, ea per erat facilisis. Ad clita utroque vel, in stet animal meliore per. An audire ponderum disputando usu, eu nam ipsum clita menandri, cu tempor maiestatis persequeris quo.</p>
</aside>
</main>
CSS
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,
samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,
article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video
{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}
*,*:before,*:after{box-sizing:inherit}
*:before,*:after{content:''}
html{box-sizing:border-box}
body{line-height:1}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}
nav ul,ul li{list-style:none}
blockquote,q{quotes:none}
blockquote:before,blockquote:after,q:before,q:after{content:none}
a{margin:0;padding:0;font-size:100%;vertical-align:baseline;background:transparent;text-decoration:none;color:inherit}
ins{background-color:#ff9;color:#000;text-decoration:none}
mark{background-color:#ff9;color:#000;font-style:italic;font-weight:bold}
del{text-decoration:line-through}
abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help}
table{border-collapse:collapse;border-spacing:0}
hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}
input,select{vertical-align:middle}
html, body {
font-family: Lato;
font-size: 16px;
}
header {
background-color: #FB7524;
color: #fff;
display: flex;
justify-content: space-between;
border-bottom: 20px solid #D74411;
margin-bottom: 30px;
}
header > * {
}
header > h1 {
font-size: 2rem;
font-weight: 700;
align-self: center;
}
nav {
font-size: 0;
}
nav > a {
font-size: 1.1rem;
display: inline-block;
width: 100px;
padding: 40px 0;
text-align: center;
margin-left: 10px;
background-color: #D74411;
}
nav > a:first-child {
margin-right: 0;
}
main {
display: flex;
justify-content: space-between;
}
section#main {
width: 60%;
margin-left: 40px;
}
section#main #intro {
margin-bottom: 30px;
}
section#main #intro h1 {
font-size: 2rem;
font-weight: 400;
margin-bottom: 10px;
}
section#main #intro p {
font-size: 1.1rem;
}
section#main article {
margin-top: 20px;
}
section#main article h2 {
font-size: 1.3rem;
font-weight: 400;
margin-bottom: 10px;
}
section#main article p {
font-size: 1.1rem;
text-align: justify;
}
aside {
transition: 0.3s all ease-out, margin 1ms,
bottom 0.2s;
width: 30%;
min-width: 300px;
max-height: 300px;
margin: 0 40px 0 20px;
background-color: #FB7524;
border-top: 20px solid #D74411;
padding: 20px;
}
aside h3 {
font-size: 1.3rem;
font-weight: 400;
color: #fff;
margin-bottom: 20px;
}
aside p {
font-size: 1.1rem;
color: #fff;
text-align: justify;
}
#media (max-width: 750px) {
aside {
height: 200px;
width: auto;
margin: 0;
position: fixed;
bottom: -100px;
opacity: 0.3;
}
aside:hover {
bottom: 0;
opacity: 1;
}
}
Here is a JSFiddle.
You're giving your element an empty content :before & :after which is messing with your styles. Is there a particular reason why you're applying them to every element?
Remove the :before & :after and it should work as expected.
CSS
*:before,*:after{content:''} /* Remove this */
JSFiddle
Why is this happening?
Because with the :before & :after inside of your flex container, it sees 4 elements instead of the 2 you want the styles to apply to. I created an example of what is happening:
Example: Extra in-flow elements (your issue)
You need to set the header to flex: 1. This should remove the unwanted margin and lets all the flexible items be the same length, regardles of its content:
header > h1 {
flex: 1;
}

Equal vertical spacing for buttons in different divs

Currently how it looks on page:
The goal: I'm trying to make the orange buttons set at an equal height regardless of the (blurred) text above it.
Relevant SCSS:
.medium-2 {
padding: .5rem;
background-color: white;
box-shadow: 0px 0px 5px 3px rgba(0,0,0,0.10);
margin-left: 2.5em;
text-align: center;
float: left;
width: 20%;
height: 450px;
h4 {
font-size: 16px;
border: none;
color: #5d5d5d;
font-family: $font-family-sans-serif;
}
p {
padding-bottom: 10%;
}
.button {
text-align: center;
}
}
Is there a non-hacky way to do this? Right now my only fix is to go into the html.erb file and add in some additional padding-down to the smaller block of p to push the orange button down in place.
Flexbox can easily solve this for you.
.content {
height: 200px;
width: 200px;
border: 1px solid;
display: inline-flex;
flex-direction: column;
margin-right: 10px;
}
p {
margin: 0;
}
button {
margin-top: auto;
width: 200px;
}
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Suscipit rerum neque laboriosam perspiciatis sapiente optio ipsam ea magni, accusantium eos quaerat ullam facilis hic quo aperiam a iure porro inventore.</p>
<button>Button</button>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet</p>
<button>Button</button>
</div>

Resources