I'm creating a responsive, mobile first website and I am having a problem where the content within the #news section won't stay within that section as the browser resizes.
When this happened originally the content would expand and cover the footer area, so I searched and found someone saying I should put overflow: auto on the section but as you'll see in the screenshots this simply makes the content go behind the footer section which I also don't want.
What I am wondering is how can I make it to where the news section will stay above the footer and resize as the browser expands.
Here's a codepen that reproduces the issue using dummy images!! http://codepen.io/marlee/pen/OMeKWa
Let's start with screen shots:
What I'm showing here is when I expand the window the date and link disappear behind the footer section.
Here is the HTML for this section:
<section id="news">
<h2>Latest News</h2>
<line></line>
<ul>
<li>
<img src="images/tech.jpg" alt="New Product Strategy for SharePoint Flex in 2016" />
<small>19 January 2016</small>
LookOut Software accelerates innovation with SharePoint Flex, unveils product strategy for Spring and Summer 2016
</li>
<li>
<img src="images/world-economic-forum.png" alt="LookOut Software Chairman to participate in World Economic Forum in Toronto 2016" />
<small>5 February 2016</small>
LookOut Software Chairman to participate in the World Economic Forum Annual Meeting 2016
</li>
<li>
<img src="images/health.jpg" alt="LookOut Software joins the fight against the Zika virus" />
<small>12 February 2016</small>
LookOut Software announces partnership with the World Health Organization to combat Zika virus
</li>
<li>
<img src="images/render-logo.jpg" alt="LookOut founder to speak at Render Conference in Oxford" />
<small>20 February 2016</small>
LookOut Software founder and CEO to speak at Render Conference in Oxford, UK this April
</li>
</ul>
</section>
/* Footer */
<footer>
<div class="footer-top">
<div class="product-column">
<h4>Products</h4>
<ul class="products">
<li>
SharePoint Flex
</li>
<li>
Flex Platform
</li>
<li>
Flex Enterprise
</li>
<li>
Pricing
</li>
</ul>
</div>
<div class="resources-column">
<h4>Resources</h4>
<ul class="resources">
<li>
Documentation
</li>
<li>
Blog
</li>
<li>
Get Started
</li>
</ul>
</div>
<div class="about-column">
<h4>About</h4>
<ul class="about">
<li>
About Us
</li>
<li>
Customers
</li>
<li>
Partners
</li>
</ul>
</div>
<div class="support-column">
<h4>Support</h4>
<ul class="support">
<li>
Help
</li>
<li>
Contact
</li>
<li>
Open a ticket
</li>
</ul>
</div>
</div>
<div class="footer-bottom">
<img src="images/lookout-temp.png">
<p>© 2016 LookOut Software</p>
</div>
</footer>
And the CSS:
/* Latest News Section */
#news{
height: 97rem;
background-color: white;
box-shadow: 0 0 2px rgba(6,8,8,0.15);
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
overflow: auto;
}
#news h2{
text-align: center;
}
line{
display: block;
width: 30%;
height: 1px;
background: #e8e8e8;
}
#news ul{
display: flex;
flex-flow: column;
list-style: none;
padding-left: 0;
}
#news li{
margin: 1em .5em;
}
#news img{
width: 100%;
}
#news a{
text-decoration: none;
color: #3a3a3a;
font-size: 1rem;
}
/* Footer CSS*/
/* Footer Top */
.footer-top{
background-color: #F0F0F0;
height: 24rem;
display: flex;
flex-flow: row wrap;
}
.footer-top ul{
list-style-type: none;
padding-left: 1.5rem;
}
.footer-top h4{
padding-left: 1.5rem;
margin-bottom: .5rem;
}
.footer-top a{
text-decoration: none;
color: #3a3a3a;
font-size: 1rem;
}
.resources-column, .about-column, .product-column{
padding: .5rem;
}
.support-column{
padding-left: 2.3rem;
}
/* Footer Bottom */
.footer-bottom{
background-color: #F6F6F6;
height: 10rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.footer-bottom img{
height: 6.25rem;
width: 15.625rem;
}
.footer-bottom p{
font-size: .80rem;
}
Any help is appreciated!
You've limited the height of the #news section with height: 97rem;.
This fixed height prevents the layout from adjusting to different screen sizes.
Instead of this:
#news { height: 97rem; }
Try this:
#new { min-height: 97rem; }
And you don't need the overflow: auto anymore.
Related
I'm new to HTML and CSS and to improve my skills i've been trying to recreate differnt sites by myself. I'm currently trying to recreate the notion home page but i have an issue. my img div is not centring? This is probably an easy fix but if someone could help i'd apprectiate it :)
Here is my HTML:
#import url("https://fonts.googleapis.com/css2?family=Inter:wght#400;500;700&display=swap");
:root {
--primary-text: #111111;
--secondary-text: #91908f;
--background: #fffefc;
--btn-primary: #e16259;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: var(--b);
font-family: "Inter", sans-serif;
}
/* NAV */
.nav {
width: 100;
}
.logo {
max-width: 100%;
height: 55px;
margin-right: 70px;
margin: 15px 50px;
}
a,
a:link,
a:visited {
color: #111111;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.nav ul {
display: flex;
padding: 35px;
list-style: none;
}
.nav ul li {
padding-right: 20px;
text-decoration: none;
color: #91908f;
}
.nav {
float: right;
}
/* HERO */
.nav-img {
display: flex !important;
align-items: center;
justify-content: center;
}
<img class="logo" src="img/logo.png" alt="Notion Logo">
<div class="nav">
<ul>
<li>Product</li>
<li>Download</li>
<li>Resources</li>
<li>Pricing</li>
<li>Careers</li>
<li><span>|</span></li>
<li>Sign Up</li>
<li>Log In</li>
</ul>
</div>
<div class="hero">
<div class="hero-img">
<img src="img/hero.webp" alt="Illustration of 3 people using laptop computers on seperate desks with different expressions">
</div>
<h1>All-in-one workspace</h1>
<h4>One tool for your whole team. Write, plan, and get organized.</h4>
<form action="">
<input type="text" placeholder="Enter your email...">
<button class='btn-primary' type="submit">Sign Up</button>
</form>
<p>For teams & individuals - web, mobile, Mac, Windows</p>
</div>
..
There are different things you need to consider when learning to code, first of all, it's important to use the new html5 semantic element header where you can place your logo and nav
<header>
<img src="logo.png" alt="Notion Logo">
<nav>
Product
Download
Resources
Pricing |
Careers
Sign Up
Log In
</nav>
</header>
*note: a nav element doesn’t have to contain a list as mentioned in MDN, and you can style them easily. The img centering issue came from the header wrong styling .nav{float: right;} .nav{ width: 100} needs to have px, %, or vw example .nav{width: 100px;}, .nav{width: 60vw;}, .nav{width: 60%;} then you can easily center the other elements vertically like below
.center-vertically {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
<header>
<div class="header-sub">
<img class="logo" src="img/logo.png" alt="Notion Logo" />
<nav>
Product
Download
Resources
Pricing |
Careers
Sign Up
Log In
</nav>
</div>
</header>
<div class="center-vertically">
<div class="centered-item">
<img src="https://www.notion.so/cdn-cgi/image/f=auto,w=1080,q=100/front-static/pages/product/hero.png" alt="Illustration of 3 people using laptop computers on seperate desks with different expressions" />
</div>
<h1>All-in-one workspace</h1>
<h4>One tool for your whole team. Write, plan, and get organized.</h4>
<form action="">
<input type="text" placeholder="Enter your email..." />
<button class="btn-primary" type="submit">Sign Up</button>
</form>
<p>For teams & individuals - web, mobile, Mac, Windows</p>
<div class="centered-item">anything you want to add</div>
</div>
You can style your header, and there is an awesome resource to follow to learn properly Freecodecamp
Trying out CSS style and would like to know reason of not getting effect of
nav {
position: absolute;
background: black;
padding: 2rem;
width: calc(100% -4em);
height: calc(100vh - 4em);
}
.cacel_btn {
width: 18px;
float: right;
cursor: pointer;
}
ul {
list-style-type: none;
margin: 10% auto 0 auto;
padding: 0;
display: grid;
grid-template-columns: repeat(4, 25%);
width: 80%;
}
<nav id="overlay">
<img src="images/cancel_button.svg" class="cancel_btn" id="cancel_btn">
<ul>
<li>
home
<span>where you feel good</span>
</li>
<li>
about us
<span>we are fantastic</span>
</li>
<li>
service
<span>we are there for you</span>
</li>
<li>
contact
<span>just come over</span>
</li>
</ul>
</nav>
Is there any problem with grid system of CSS?
My goal is to design the menu which should look like in attached image file.
in your html code there is the class "cacel_btn" instead of "cancel_btn".
Can you post your html-header? i want to see how you´ve linked the stylesheet.
Why are you using a class and an id with "cancel_btn"?
I have this list at the bottom of the page, and when I hover over each number, a sentence shows up, however, I want the paragraph with the sentence to show centered in the middle of the page, so pretty much all in the same position, how can i do that?
Images attached to help 1-2
.dotMenu {
margin-left: auto;
text-align: center;
margin-right: auto;
margin-bottom: -50px;
position: relative;
margin-left: 5%;
margin-right: 5%;
}
.dotMenu ul li {
height: 30px;
width: 30px;
background-color: #222954;
border-radius: 50%;
text-align: center;
font-family: Lovelo Pro;
line-height: 30px;
display: inline-block;
margin-left: 3px;
margin-right: 3px;
margin-top: 5px;
margin-bottom: 5px;
}
.dotMenu ul li a {
text-decoration: none;
color: #FDBA3B;
}
.dotMenu ul li:hover {
background-color: white;
}
.dotMenu ul li p {
display: none;
}
.dotMenu ul li:hover p {
display: inline-block;
position: absolute;
}
<div class="dotMenu">
<ul>
<li>1
<p>Cascading Web Design with Feature Queries</p>
</li>
<li>2
<p>Lint the Web Forward With Sonarwhal</p>
</li>
<li>3
<p>Web Content Accessibility Guidelines—for People Who Haven't Read Them</p>
</li>
<li>4
<p>Jobs-to-Be-Done in Your UX Toolbox</p>
</li>
<li>5
<p>Levelling Up for Junior Developers</p>
</li>
<li>6
<p>Designing a Remote Project</p>
</li>
<li>7
<p>Automating Your Accessibility Tests</p>
</li>
<li>8
<p>Stop Leaving Animation to the Last Minute</p>
</li>
<li>9
<p>Styling Components - Typed CSS With Stylable</p>
</li>
<li>10
<p>Christmas Gifts for Your Future Self: Testing the Web Platform</p>
</li>
<li>11
<p>Teach the CLI to Talk Back</p>
</li>
<li>12
<p>Design Systems and CSS Grid</p>
</li>
<li>13
<p>Getting Hardboiled with CSS Custom Properties</p>
</li>
<li>14
<p>Why Design Systems Fail</p>
</li>
<li>15
<p>Accessibility Through Semantic HTML</p>
</li>
<li>16
<p>Care and Feeding of Burnout</p>
</li>
<li>17
<p>Feeding the Audio Graph</p>
</li>
<li>18
<p>Designing for Mobile Performance</p>
</li>
<li>19
<p>Want to Break Out of Comparison Syndrome? Do a Media Detox</p>
</li>
<li>20
<p>Is Your Website Accidentally Sexist?</p>
</li>
<li>21
<p>Knowing the Future - Tips for a Happy Launch Day</p>
</li>
<li>22
<p>Design Systems and Hybrids</p>
</li>
<li>23
<p>Refactoring Your Way to a Design System</p>
</li>
<li>24
<p>All That Glisters</p>
</li>
</ul>
</div>
Give your p tags a position of absolute, aligned to the left, with a 100% width and a text-align of center.
Note: you may have to give a parent div a position:relative if you want the p tags to be centered relative to the container, not the page.
li p{
display: none;
position:absolute;
left: 0;
width: 100%;
text-align: center;
}
.flex{
display:flex;
list-style:none;
padding: 0;
}
li{
background: dodgerblue;
margin-right: 5px;
border-radius: 50%;
}
li p{
display: none;
position:absolute;
left: 0;
width: 100%;
text-align: center;
}
li a{
text-decoration:none;
color: #fff;
display:block;
width: 30px;
height: 30px;
display:flex;
align-items: center;
justify-content:center;
}
li a:hover ~ p{
display: block;
}
<ul class="flex">
<li>1<p>Cascading Web Design with Feature Queries</p></li>
<li>2<p>Lint the Web Forward With Sonarwhal</p></li>
<li>3<p>Web Content Accessibility Guidelines—for People Who Haven't Read Them</p></li>
<li>4<p>Jobs-to-Be-Done in Your UX Toolbox</p></li>
<li>5<p>Levelling Up for Junior Developers</p></li>
<li>6<p>Designing a Remote Project</p></li>
<li>7<p>Automating Your Accessibility Tests</p></li>
<li>8<p>Stop Leaving Animation to the Last Minute</p></li>
<li>9<p>Styling Components - Typed CSS With Stylable</p></li>
<li>10<p>Christmas Gifts for Your Future Self: Testing the Web Platform</p></li>
<li>11<p>Teach the CLI to Talk Back</p></li>
<li>12<p>Design Systems and CSS Grid</p></li>
<li>13<p>Getting Hardboiled with CSS Custom Properties</p></li>
<li>14<p>Why Design Systems Fail</p></li>
<li>15<p>Accessibility Through Semantic HTML</p></li>
<li>16<p>Care and Feeding of Burnout</p></li>
<li>17<p>Feeding the Audio Graph</p></li>
<li>18<p>Designing for Mobile Performance</p></li>
<li>19<p>Want to Break Out of Comparison Syndrome? Do a Media Detox</p></li>
<li>20<p>Is Your Website Accidentally Sexist?</p></li>
<li>21<p>Knowing the Future - Tips for a Happy Launch Day</p></li>
<li>22<p>Design Systems and Hybrids</p></li>
<li>23<p>Refactoring Your Way to a Design System</p></li>
<li>24<p>All That Glisters</p></li>
</ul>
I have a navigation bar with hyperlinks to other pages. I decided to use different divisions for each hyperlink because I couldn't get them to spread out. When I execute this on my browser, two of the hyperlinks(both the right ones) are slightly below the other ones. I don't know if that is because of my mac or if it's an error in the code. Could someone please tell me how I can make sure all hyperlinks are evenly lied up in 2 lines?
.navbar {
padding: 15px;
font-size: 28pt;
background-color: #F64C72;
position: relative;
top: 20px;
text-align: center;
margin: auto;
font-size: 17pt;
}
.connectp1 {
text-align: left;
}
.connectp2 {
text-align: center;
}
.connectp3 {
text-align: right;
}
.connectp4 {
text-align: left;
}
.connectp5 {
text-align: center;
}
.connectp6 {
text-align: right;
}
<div class="navbar">
<div>
<div class="connectp1">
First Peoples
</div>
<div class="connectp2">
Natives And Newcomers
</div>
<div class="connectp3">
Provincial Centre
</div>
</div>
<div>
<div class="connectp4">
Industrializing City
</div>
<div class="connectp5">
Wars And Crises
</div>
<div class="connectp6">
The Modern Metropolis
</div>
</div>
</div>
You don't need extra layers to spread out. Inline elements like <a> are better for this kind of menus, so just keep it simple. The code bellow will split in two lines only if required.
.navbar {
padding: 15px;
background-color: #F64C72;
text-align: center;
font-size: 17px;
}
.menu {
display: inline-block;
margin: 10px auto;
white-space: nowrap;
}
nav a {
display: inline-block;
padding: 5px;
white-space: normal;
vertical-align: top;
}
<nav class="navbar">
<div class="menu">
First Peoples
Natives And Newcomers
Provincial Centre
</div>
<div class="menu">
Industrializing City
Wars And Crises
The Modern Metropolis
</div>
</nav>
However I recommend you considering some improvements in your design to help the menu look more tidy.
This looks like a perfect opportunity to use flexbox setting justify-content. We can just work with a div to hold all the nav and then a div for each row then the links directly.
flexbox handles the distribution of the a elements in our instance, while setting justify-content: space-between determines how the a elements are spaced.
.navbar {
padding: 15px;
font-size: 28pt;
background-color: #F64C72;
position: relative;
top: 20px;
text-align: center;
margin: auto;
font-size: 17pt;
}
.navbar > div {
display:flex;
justify-content: space-between;
}
<div class="navbar">
<div>
First Peoples
Natives And Newcomers
Provincial Centre
</div>
<div>
Industrializing City
Wars And Crises
The Modern Metropolis
</div>
</div>
With IE 10 you will need to prefix with -ms- and it won't work at all with older versions of IE if you need to support IE 9 and earlier. See: https://css-tricks.com/almanac/properties/j/justify-content/
You would be much better off using unordered lists (ul) with list items (<li>), and then displaying the lists as table rows/table cells as in the snippet below, and vertically aligning to top. Btw, your current css includes duplication, there is no need to created 2 different classes to text-align to the right (e.g)
Feel free to adjust the snippet ( I reduced the huge font size! - so that the adjustments could be seen in the snippet)
* {
margin: 0px;
padding: 0px;
}
nav {
margin: auto;
top: 20px;
padding: 20px;
font-size: 13pt;
background-color: #F64C72;
text-align: center;
}
nav ul {
margin: 0px;
list-style-type: none;
vertical-align: top;
display: table-row;
}
ul li {
display:table-cell;
}
ul li a {
text-decoration: none;
}
<nav>
<ul>
<li>First Peoples </li>
<li>Natives And Newcomers</li>
<li>
Provincial Centre
</li>
</ul>
<ul>
<li class="">Industrializing City
</li>
<li class="">
Wars And Crises
</li>
<li class="">
The Modern Metropolis
</li>
</ul>
</nav>
Use HTML5 semantic elements when possible. In your case, the nav element is the proper tool for the job. MDN shows:
nav {
border-bottom: 1px solid black;
}
.crumbs ol {
list-style-type: none;
padding-left: 0;
}
.crumb {
display: inline-block;
}
<nav class="crumbs">
<ol>
<li class="crumb">Acme</li>
<li class="crumb">Foo</li>
<li class="crumb">Bar</li>
</ol>
</nav>
<h1>Jump Bike 3000</h1>
<p>This BMX bike is a solid step into the pro world. It looks as legit as it rides and is built to polish your skills.</p>
<div> elements are block-level elements, so take up 100% of the width of a 'row' by default. While you can correct this by simply changing their display to inline-block, I would recommend replacing them with <span> tags instead (which are inline-block by default):
.navbar {
padding: 15px;
font-size: 28pt;
background-color: #F64C72;
position: relative;
top: 20px;
text-align: center;
margin: auto;
font-size: 17pt;
}
.connectp1 {
text-align: left;
}
.connectp2 {
text-align: center;
}
.connectp3 {
text-align: right;
}
.connectp4 {
text-align: left;
}
.connectp5 {
text-align: center;
}
.connectp6 {
text-align: right;
}
<div class="navbar">
<div>
<span class="connectp1">
First Peoples
</span>
<span class="connectp2">
Natives And Newcomers
</span>
<span class="connectp3">
Provincial Centre
</span>
</div>
<div>
<span class="connectp4">
Industrializing City
</span>
<span class="connectp5">
Wars And Crises
</span>
<span class="connectp6">
The Modern Metropolis
</span>
</div>
</div>
Note that you're also likely looking for float: left and float: right
rather than text-align: left and text-align: right, in order to separate out your elements. There's no float: center, though this isn't needed. You can also combine your selectors in this regard to save space, as can be seen in the following:
.navbar {
padding: 15px;
font-size: 28pt;
background-color: #F64C72;
position: relative;
top: 20px;
text-align: center;
margin: auto;
font-size: 17pt;
}
.connectp1, .connectp4 {
float: left;
}
.connectp3, .connectp6 {
float: right;
}
<div class="navbar">
<div>
<span class="connectp1">
First Peoples
</span>
<span class="connectp2">
Natives And Newcomers
</span>
<span class="connectp3">
Provincial Centre
</span>
</div>
<div>
<span class="connectp4">
Industrializing City
</span>
<span class="connectp5">
Wars And Crises
</span>
<span class="connectp6">
The Modern Metropolis
</span>
</div>
</div>
ive been stuck trying to float these pictures into two columns for days. They just stay centered no matter how small i make them. They will be very small and still not float, one time they did float but i cant get back to that and even when they did they were all messy and not making columns, i just want to make columns. i used the .group1 and .group2 classes to target the things to float
<ul class="secondary-content group">
<div class="group1">
<li>
<img src= "MB6.jpg" alt="Wonderful evening">
<p>I've had a perfectly wonderful evening. But this wasn't it.</p>
<p>-Groucho Marx</p>
</li>
<li>
<img src="love3.jpg" alt="Marilyn Monroe">
<p>"A man's only as old as the woman he feels."</p>
<p>-Groucho Marx</p>
</li>
<li>
<img src="MB5.png">
<p>"I intend to live forever, or die trying."</p>
<p>-Groucho Marx</p>
</li>
</div>
<div class="group2">
<li>
<img src="MB2.jpg">
<p>Groucho: "Get outta here before I get arrested."</p>
<p>Chico: "Nah I'd like to stay and see that."</p>
<p>-Groucho Marx</p>
</li>
<li>
<img src="MB4.jpeg">
<p>"honk honk"</p>
<p>Harpo Marx</p>
</li>
<li>
<img src="MB9.jpg">
<p>Groucho: "Do you follow me?"</p>
<p>Margaret Dumont: "Yes!"</p>
<p>Groucho: "Well, you better stop following me, or I'll have you arrested."</p>
</li>
</div>
</ul>
* {
box-sizing: border-box;
}
a {
text-decoration: none;
}
img {
max-width: 100%;
}
a h1 {
text-align: center;
}
.main-header{
padding-top: 50px;
height: 1000px;
background: linear-gradient(#fff, transparent 60%),
linear-gradient(0deg, #fff, transparent 50%),
url('../MarxBros.jpg') no-repeat center;
}
.intro{
text-align: center;
}
.secondary-content{
width: 40%;
padding-left: 20px;
padding-right: 20px;
margin: 0 auto;
max-width:300px;
text-align: center;
;
}
.secondary-content img{
max-width:300px;
}
.group1 li {
float: left;
}
.group2 li {
float:right
}
.group:after {
content: "";
display: table;
clear: both;
}
You need to fix your HTML structure. Only <li> elements can be direct children of <ul> elements. In this new structure I created two <ul> elements and changed the float to the <ul>'s rather than the <li>'s: jsfiddle
<ul class="secondary-content group group1">
<li>
<img src= "MB6.jpg" alt="Wonderful evening">
<p>I've had a perfectly wonderful evening. But this wasn't it.</p>
<p>-Groucho Marx</p>
</li>
...
</ul>
<ul class="secondary-content group group2">
<li>
<img src="MB2.jpg">
<p>Groucho: "Get outta here before I get arrested."</p>
<p>Chico: "Nah I'd like to stay and see that."</p>
<p>-Groucho Marx</p>
</li>
...
</ul>
.group1 {
float: left;
}
.group2 {
float:right
}
.group:after {
content: "";
display: table;
clear: both;
}