height=100%/height=100vh going beyond screen - html

I have set height:100% but its going beyond screen, how do I restrict height to not go beyond footer.
Overflow scrollbars should not go beyond footer.
If you check the scroll bar for #two , the lower end of it will not be visible but I want #two height to be restricted till footer, so lower end of the scroll should be above footer.
p {
display: block;
background: #eee;
}
#one>p {
height: 100%;
}
#two>p {
height: 100vh;
overflow-y: scroll;
}
.nimbusfooter {
left: 0;
right: 0;
bottom: 0;
position: fixed;
color: white;
background: black;
padding: 5px;
font-size: 10pt;
line-height: 23.5px;
}
.footernav {
color: white;
text-decoration: underline;
}
.footernav1 {
color: white;
text-decoration: underline;
}
<div id="one" style="height:50px">
<p>100% Height</p>
</div>
<div id="two" style="height:50px">
<p>100vh Height</p>
</div>
<footer class="nimbusfooter">
<span>© <span>{{currentYear}}</span>{{'FOOTER' | translate}}</span>
<span style="float:right;">
<a class = "footernav" >{{'ACCESSIBILITY' | translate}}</a>
<a class = "footernav1" >{{'PRIVACY_AND_LEGAL' | translate}}</a>
<a class = "footernav" >{{'SITEMAP' | translate}}</a>
</span>
</footer>

Is this what you're looking for? Marked up code below. Pop a comment on if not.
/* made the body 100vh tall with no margins so no overflow bars will appear on the body */
body {
margin:0;
height: 100vh;
/*make children flex items so we can use flex-grow and flex-shrink to control their size */
display: flex;
flex-direction:column;
}
body > div {
/* make the div elements (i.e. not the footer which is a <footer> element) grow to fit the available space */
flex-grow:1;
}
p {
/* removed the display: block from these. not really needed */
background: #eee;
height: 100%;
}
#two {
overflow-y: scroll;
}
.nimbusfooter {
color: white;
background: black;
padding: 5px;
font-size: 10pt;
line-height: 23.5px;
flex-grow:0;
flex-shrink:1;
}
.footernav, .footernav1 {
color: inherit; /* changed this from white to inherit, so always adopts parent value */
text-decoration: underline;
}
<div id="one" style="height:50px">
<p>100% Height</p>
</div>
<div id="two" style="height:50px">
<p>100vh Height</p>
</div>
<footer class="nimbusfooter">
<span>© <span>{{currentYear}}</span>{{'FOOTER' | translate}}</span>
<span style="float:right;">
<a class="footernav">{{'ACCESSIBILITY' | translate}}</a>
<a class="footernav1">{{'PRIVACY_AND_LEGAL' | translate}}</a>
<a class="footernav">{{'SITEMAP' | translate}}</a>
</span>
</footer>

Related

Why scrollable cards height are not increasing according to his content

I designed the scrollable cards. The cards are only for mobile screens. The current issue is that more data gets encapsulated inside the scrollable wrapper as the content grows. No matter how long the content is, I want the div's height to increase. Is there a fix for this design that makes the card's height rise in proportion to its contents?
The read more functionality is implemented, but I didn't add it to the snippet. By default, all the content will be the same. But on read more, the content can vary. So, I want the design to be fixed so read more content does not affect the card.
By default:
On clicking read more/content increases:
.scrolling-wrapper {
-webkit-overflow-scrolling: touch;
height: 474px;
width: 100%;
padding-inline: 40px;
position: relative;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
z-index: 0;
padding-top: 150px;
visibility: visible;
}
.scrolling-wrapper::-webkit-scrollbar {
display: none;
}
.card {
width: 100%;
flex: 0 0 auto;
background-color: green;
border-radius: 20px;
position: relative;
margin-inline-end: 10px;
}
.our-member-owner-card-image {
position: absolute;
top: -66px;
z-index: 10;
left: 29%;
}
.card-content {
position: absolute;
padding-top: 38px;
}
.member-detail {
padding-top: 55px;
line-height: 1.7;
}
.member-detail h3 {
text-align: center;
color: #263244;
font-weight: 700;
font-family: "Lato";
}
.member-detail p {
text-align: center;
color: #737c89;
}
.member-description {
padding-inline: 20px;
color: #263244;
line-height: 1.6;
padding-top: 9px;
font-weight: 500;
font-size: 16px;
font-style: normal;
font-weight: 500;
}
.member-description .read-more {
color: #eb644c;
text-decoration: underline;
cursor: pointer;
}
<div class="scrolling-wrapper">
<div class="card">
<div class="our-member-owner-card-image">
<img width="140px" src="https://images.unsplash.com/photo-1579279219378-731a5c4f4d16?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8bXIlMjBiZWFufGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=500&q=60" />
</div>
<div class="card-content">
<div class="member-detail">
<h3 id="mobile-member-name">Mr bean</h3>
<p id="mobile-member-designation">Actor</p>
</div>
<div class="member-description">
<span id="mobile-member-description">
Mr Bean has extensive work experience during his career of more than 25 years in the film industry.
</span>
<span id="mobile-more" >Some dummy text </span>
<span id="mobile-member-description-readmore" class="readMoreLink read-more" >Read less</span>
</div>
</div>
</div>
<div class="card">
<div class="our-member-owner-card-image">
<img width="140px" src="https://images.unsplash.com/photo-1579279219378-731a5c4f4d16?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8bXIlMjBiZWFufGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=500&q=60" />
</div>
<div class="card-image-shadow"></div>
<div class="card-content">
<div class="member-detail">
<h3 id="mobile-member2-name">Mr bean</h3>
<p id="mobile-member2-designation">Actor</p>
</div>
<div class="member-description">
<span id="mobile-member2-description">
Mr Bean has extensive work experience during his
career of more than 25 years in the film industry
</span>
<span id="mobile-more2" >Some dummy text </span>
<span id="mobile-member2-description-readmore" class="readMoreLink read-more" " >Read less</span
>
</div>
</div>
</div>
</div>
As I understood your question, your issue is that the content is pushing out because you have defined an absolute height for the container. Let the content determine the height dynamically. Instead of using height and max-height, try using min-height. That way, if the content needs more space, it can grow.
So removing this should make the cards grow based on the size of the content
.scrolling-wrapper {
height: 474px;
}
I think adding
min-height: fit-content
to .scrolling-wrapper will do what you want

dropdown menu content issues/problems

* {
box-sizing: border-box;
}
body {
font-family: 'Times New Roman', Times, serif;
padding: 10px;
background: #f1f1f1;
}
.header {
text-align: center;
background-color: rgb(255, 255, 255);
padding: 20px;
margin-bottom: 15px;
}
.header h1{
font-size: 30px;
}
.navbar {
overflow: hidden;
background-color: rgb(52, 52, 52);
position: sticky;
top: 0;
box-shadow: 5px 5px 10px rgba(52, 52, 52, 0.753);
}
.drop {
float: left;
overflow: hidden;
}
.drop .dropbtn {
font-size: 20px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
}
.navbar .a {
float: left;
display: block;
color: white;
text-decoration: none;
text-align: center;
padding: 14px 16px;
font-size: 20px;
}
.navbar .a:hover {
background-color: white;
color: black;
}
.drop-content {
display: none;
position: absolute;
background-color: rgb(234, 234, 234);
min-width: 160px;
z-index: 1;
}
.drop-content .a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.drop:hover .drop-content {
display: block;
}
.leftside {
float: left;
width: 75%;
}
.rightside {
float: left;
width: 25%;
padding-left: 20px;
}
.fakeimg {
background-color: rgb(176, 176, 176);
width: 100%;
padding: 20px;
}
div .fakeimg:hover {
border: 1px solid black;
cursor: pointer;
}
.card {
background-color: white;
padding: 20px;
margin-top: 20px;
}
.row:after {
content: "";
display: table;
clear: both;
}
.footer {
padding: 30px;
text-align: center;
background-color: rgb(248, 248, 248);
margin-top: 20px;
}
/* Responsive layout - when the screen is less than 800px wide, make the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 800px) {
.leftside, .rightside {
width: 100%;
padding: 0;
}
}
/* Responsive layout - when the screen is less than 400px wide, make the navigation links stack on top of each other instead of next to each other */
#media screen and (max-width: 400px) {
.navbar a {
float: none;
width: 100%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<!--This is a link to the CSS.-->
<link rel="stylesheet" href="first_webpage.css">
<body>
<!--This is our header.-->
<div>
<header class="header">
<h1>First Webpage</h1>
</header>
</div>
<!--This is a navigation bar.-->
<div class="navbar">
Home
Projects
Contact
<div class="drop">
<button class="dropbtn">Dropdown
<i></i>
</button>
<div class="drop-content">
Link 1
Link 2
Link 3
</div>
</div>
About
</div>
<!--This is the first and main colum.-->
<div class="row">
<div class="leftside">
<div class="card">
<h2>Title One</h2>
<h5>Description, May 31, 2022</h5>
<div class="fakeimg" style="height: 200px;">Image</div>
<figcaption>Section 1.1 City</figcaption>
<p>This is subsection title</p>
<p>This is the first paragraph of the main section.
This also my first webpage. It definitly looks
like something from the <i><a href="https://www.nytimes.com/">
New York Times</a></i>. It's coming out pretty good;
i just need to continue taking it one step at a time.
Nonetheless, I will contue on with this section and
not bore you. Enjoy the rest of my layout.</p>
</div>
<div class="card">
<h2>Title Two</h2>
<h5>Description, May 31, 2022</h5>
<div class="fakeimg" style="height: 200px;">Image</div>
<figcaption>Section 1.2 Flowers</figcaption>
<p>This is a second section Title</p>
<p>This is a second paragraph, I really don't know
what to write. It's not like this is an engligh
101 class. i mean jesus. Talking about jesus, do
you know they're making a jesus game... i mean
what has the gaming industry come to?</p>
</div>
</div>
<div class="rightside">
<div class="card">
<h3>About Me</h3>
<div class="fakeimg" style="height: 100px;">Image</div>
<p>Some text about me so that the visiter may
know a bit more about the developer that they're
interested in...</p>
</div>
<div class="card">
<h3>Popular Posts</h3>
<div class="fakeimg"><p>Image</p></div>
<div class="fakeimg"><p>Image</p></div>
<div class="fakeimg"><p>Image</p></div>
<div class="fakeimg"><p>Image</p></div>
</div>
<div class="card">
<h3>Social Media</h3>
<p>Some social media pages that individuals can
follow me on....</p>
</div>
</div>
</div>
<!--This is a footer-->
<div class="footer">
<p>Footer</p>
</div>
</body>
</html>
I'm trying to create a dropdown menu for my dropdown button; as I create the dropdown button everything seems to be fine, however, once I put the position to "absolute" it does not allow me to view the content that is within the dropdown button even when I'm hovering over it. I tried changing the position to anything other than "absolute" and it does allow me to view the content, but it would either stretch the navigation bar down to make room for the options or place the content lower than where the button is located. Can anyone help me out with this problem? I provided the full code for my html and CSS because I think it may be clashing with another code.

CSS position relative vs absolute

I have the following page (see code snippet below). I would like to position each of the items, so that when it is a full web page, the elements are i their desired positions, but as soon as it is viewed on narrow aspect ratio (e.g. mobile phone), then the items need to fold under each other.
I can get a full web page working, using position: absolute;. I can position the items where I want. But the problem is then on a mobile devise, the items overlap each other. So I figure I need to use position: relative;.
position: relative; allows the items to fold beneath each other on a narrow browser. However, I cannot seem to position the items where I want.
In the below example, I would like to position the items as follows:
logo
title
text screen-print-one
google apple web screen-print-two
Terms of Service some#email.com
body {
font-family: "proxima-nova" ,"Helvetica", sans-serif;
}
/* logo */
.wz-logo {
text-align: center;
padding: 20px 20px 0px 20px;
}
/* title */
.wz-title {
font-size: 120%;
color: #B2D137;
text-align: center;
padding: 0 20px 40px 30px;
}
/* text */
.text-description {
padding-left: 10%;
padding-bottom: 20px;
padding-top: 20px;
width: 500px;
}
/* screen-prints */
.screen-prints {
position: relative;
float: right;
padding-right: 10%;
}
.screen-print1 {
position: relative;
top: 100px;
left: 0;
z-index: 2;
}
.screen-print2 {
position: relative;
top: -430px;
left: -120px;
z-index: 1;
}
/* store */
.store-container {
display: flex;
justify-content: left;
align-items: center;
padding-left: 10%;
}
.store-container .apple, .img-container .google, .img-container .web {
padding: 10px;
padding-left: 20px;
}
.store-container .google {
padding-top: 0px;
padding-left: 0px;
padding-right: 0px;
margin-top: 10px;
}
.store-container .apple {
padding-top: 8px;
padding-left: 0px;
padding-right: 0px;
}
.store-container .web {
padding-top: 15px;
}
/* footer */
footer .terms, footer .contact {
display:inline-block;
padding-bottom: 30px;
padding-right: 10px;
padding-left: 10px;
}
footer .contact {
padding-right: 40px !important;
}
footer a {
color: white;
text-decoration: none;
font-size: 14px;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
footer {
position:absolute;
bottom:0;
right: 0;
}
<body class="background-image">
<div class="wz-logo">
logo
</div>
<div class="wz-title">
title
</div>
<div class="text-description">
text
</div>
<div class="screen-prints">
<div class="screen-print1">screen-print-one
</div>
<div class="screen-print2">screen-print-two
</div>
</div>
<div class="store-container">
<div class="google">
google
</div>
<div class="apple">
apple
</div>
<div class="web">
web
</div>
</div>
<footer>
<div class="terms">
Terms of Service
</div>
<div class="contact">
some#email.com
</div>
</footer>
</body>
If anyone can assist with how I can position the items, I would appreciate the help. (As you can see my main problem is trying to position the screen-print-one & screen-print-two).
Thanks
hmm there are a bunch of problems with your html logic. too many divs and not wrapped logically . but i made what i could with it
see below. or jsFiddle
.wz-logo,.wz-title {
width:100%;
float:left;
text-align:center;
}
.left_text {
float:left;width:50%;
}
.left_text .store-container div{
display:inline
}
.screen-prints {
float:right;
width:50%;
text-align:right;
}
footer {
float:left;
width:100%;
text-align:right
}
footer div {
display:inline
}
#media only screen and (max-width: 460px) {
.left_text,.screen-prints,footer {
width:100%;
text-align:center;
}
}
<body class="background-image">
<div class="wz-logo">
logo
</div>
<div class="wz-title">
title
</div>
<div class="left_text">
<div class="text-description">
text
</div>
<div class="store-container">
<div class="google">
google
</div>
<div class="apple">
apple
</div>
<div class="web">
web
</div>
</div>
</div>
<div class="screen-prints">
<div class="screen-print1">screen-print-one
</div>
<div class="screen-print2">screen-print-two
</div>
</div>
<footer>
<div class="terms">
Terms of Service
</div>
<div class="contact">
some#email.com
</div>
</footer>
</body>
i suggest you use bootstrap for responsiveness . it's much easier to use

How do you align 3 DIV's side by side inside of another DIV and right justify the last DIV?

I have a simple list item that I want to format. It contains 3 DIV's. I want the first DIV to be left justified, the second DIV to be able to grow as needed, and the third DIV to be right justified. I have the three DIV's stacked side by side, but I can't figure out how to get the last DIV to right justify. This is what it looks like now:
<li *ngFor="let script of scripts" [class.selected]="script === selectedScript" (click)="onSelect(script)">
<div class="container">
<div class="left">
<span class="badge">{{script.scriptOrderID}}</span>
</div>
<div class="center">
<span>{{script.scriptName}}</span>
</div>
<div class="right">
<span class="badge2">{{script.scriptID}}</span>
</div>
</div>
</li>
This is what I want it to look like:
.container {
display: flex;
}
.left {
width: 70px;
}
.center{
display: flex;
}
.right{
}
Take a look at flexbox, easy to use, and with flex-end it'll be fast to get your blocks at the end.
<div class="line">
<div class="first_block">
</div>
<div class="text">
Hello
</div>
<div class="second_block">
</div>
</div>
.line {
height : 40px;
width : 100%;
display : flex;
flex-flow : row wrap;
background-color : gray;
}
.first_block, .second_block {
background-color : blue;
width : 40px;
}
.text {
flex-grow : 1;
}
JSFIDDLE to show you the result.
Cheers !
You can do it without all the divs in the li...
Display your list-item as table, and the span's inside it as table-cell:
* { margin: 0; padding: 0; list-style: none; box-sizing: border-box; }
ul {
width: 100%;
}
li {
width: 100%;
display: table;
margin-bottom: 2px;
}
li > span {
display: table-cell;
background: lightgrey;
}
li > span:first-child,
li > span:last-child {
background: black;
color: white;
width: 3em;
}
<ul>
<li>
<span>60</span>
<span>Click Add a Printer</span>
<span>53</span>
</li>
<li>
<span>70</span>
<span>Click "The printer I want isn't listed"</span>
<span>54</span>
</li>
<li>
<span>80</span>
<span>Select "Add a printer using a TCP/IP address or hostname" Click Next</span>
<span>55</span>
</li>
</ul>
Flexbox alternativ
* { margin: 0; padding: 0; list-style: none; box-sizing: border-box; }
ul {
width: 100%;
}
li {
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
margin-bottom: 2px;
}
li > span {
background: lightgrey;
flex-grow: 1;
}
li > span:first-child,
li > span:last-child {
background: black;
color: white;
width: 3em;
flex-grow: 0;
}
<ul>
<li>
<span>60</span>
<span>Click Add a Printer</span>
<span>53</span>
</li>
<li>
<span>70</span>
<span>Click "The printer I want isn't listed"</span>
<span>54</span>
</li>
<li>
<span>80</span>
<span>Select "Add a printer using a TCP/IP address or hostname" Click Next</span>
<span>55</span>
</li>
</ul>
You can use a code like below.
You have fixed width divs on both sides and a center div with fluid width.
That should do the trick.
.container > div {
float: left;
padding: 0 10px;
}
.left{
width: 30px;
}
.right {
width: 30px;
}
.center {
width: calc( 100% - 120px);
background: #ccc;
}
<div class="container">
<div class="left">
<span class="badge">23</span>
</div>
<div class="center">
<span>test</span>
</div>
<div class="right">
<span class="badge2">44</span>
</div>
</div>
Using flexbox you can do this:
.container {
line-height: 50px;
background: #e1e1e1;
display: flex;
justify-content: space-between;
}
.center {
flex: 1;
}
.badge,
.badge2 {
display: block;
background: purple;
color: white;
text-align: center;
padding: 0 15px;
}
<div class="container">
<div class="left">
<span class="badge">*</span>
</div>
<div class="center">
<span>The Name will grow</span>
</div>
<div class="right">
<span class="badge2">**</span>
</div>
</div>

css div formatting and alignment

How do I align as so that the sidebar and picture section run alongside the main content area with NO white spaces
JsFiddle
<div id="page-container">
<div id="mainnavigationarea">
<p>Main Navigation</p>
</div>
<div id="rosaheadersection">
<p>Header</p>
</div>
<div id="rosapicturesection">
<p>Picture Section</p>
</div>
<div id="rosachiefcontent">
<p>Main Area. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.</p>
</div>
<div id="rosasidebar-a">
<p>Sidebar.Sidebar,Sidebar, Sidebar SidebarSidebarSidebarSidebarSidebarSidebar</p>
</div>
<div id="rosafooter">
<p>footer</p>
</div>
</div>
You should wrap your main content and the sidebar content in their own div container and set that container to float:left. To remove the whitespace you need to remove the natural margin that's added to p tags.
HTML
<div id="page-container">
<div id="mainnavigationarea">
<p>Main Navigation</p>
</div>
<div id="rosaheadersection">
<p>SM Tool</p>
</div>
<div class="left-container">
<div id="rosachiefcontent">
<p>Main Area. This sets the definition titles (our individual nav item containers) to float left, which stacks them left to right, instead of one under the other. Main Area. This sets the definition titles (our individual nav item containers) to float left, which stacks them left to right, instead of one under the other. Main Area. This sets the definition titles (our individual nav item containers) to float left, which stacks them left to right, instead of one under the other.</p>
</div>
</div>
<div class="right-container">
<div id="rosapicturesection">
<p>Picture Section</p>
</div>
<div id="rosasidebar-a">
<p>Sidebar.Sidebar,Sidebar, Sidebar SidebarSidebarSidebarSidebarSidebarSidebar</p>
</div>
</div>
<div id="rosafooter">
<p>footer</p>
</div>
</div>
CSS
html,body{
margin: 0;
padding: 0;
}
p{
margin: 0;
}
.left-container{
float: left;
width:980px;
}
.right-container{
float: left;
width: 280px;
}
#rosafooter {
clear: both;
font-family: Tahoma, Arial, Helvetica, Sans-serif;
font-size: 10px;
color: #3e5667;
border-top: 1px solid #efefef;
padding: 13px 25px;
line-height: 18px;
}
#mainnavigationarea {
height: 150px;
background: #999;
}
#rosaheadersection {
height: 150px;
background: #7ac0da;
}
#rosapicturesection {
height: 150px;
background: yellow;
width: 280px;
}
#rosasidebar-a {
width: 280px;
background:#3e5667
}
#rosachiefcontent h2 {
margin: 0;
padding: 0;
}
#rosachiefcontent p {
margin: 0;
padding: 50px;
}
#rosachiefcontent {
clear: both;
overflow:auto;
margin-right: 280px;
background:#a6dbed;
width:980px;
vertical-align:top
}
#page-container {
width: 1260px;
margin: auto;
background:#fff
}
FIDDLE