White block behind elements on page! (Not Body) [duplicate] - html

This question already has answers here:
What is a clearfix?
(10 answers)
What methods of ‘clearfix’ can I use?
(29 answers)
Closed 4 years ago.
Okay so, Building an account page, and using the same kind of method we normally use when constructing pages, we seem to have this issue where it's like a large white block/space is in the background, so essentially some kind of element or div with white background colour. Only issue is, there isn't anything that should be causing this, and it most certainly isn't the body.
See image
(minor details aside, it is not finished as work has stopped due to this issue!)
The account and operative buttons elements (columns) are supposed to have a white background, while the background behind these two divs should be green. We assumed this would be the body.
body {
font-family: 'nunito', sans-serif;
/*width: 100%;*/
height: 100%;
background-color: #049E84 !important;
overflow: hidden;
align-content: center;
float: inherit;
margin-top: 0;
}
#account {
margin-top 100px;
padding: 50px;
margin-bottom: 100px;
/* font-family: 'nunito', sans-serif; */
/* float: inherit;*/
/* width: 70%;*/
/* margin-left: 19%;*/
/* margin-top: 0;*/
align-content: center;
background-color: #049E84;
}
#info {
text-align: center;
width: 60%;
height: 75%;
background-color: white;
padding: 25px;
font-family: 'nunito', sans-serif;
font-size: 35px;
color: dimgrey;
float: left;
border-radius: 60px;
}
#operativeButtons {
text-align: center;
padding: 25px;
margin-left: 30px;
background-color: white;
border-radius: 60px;
width: 15%;
height: 75%;
float: right;
}
#yourAccount {
font-family: 'nunito', sans-serif;
font: bolder;
color: #282828
}
#valid {
color: grey;
padding-top: 20px;
font-weight: bold;
}
#tickets {
color: #049e84;
}
#warning {
color: #ff0000;
}
#uname {
display: inline;
}
p {
line-height: 1;
}
.title {
padding-top: 10px;
color: black;
}
#bg {
background-color: #049e84;
}
<link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<div id="bg">
<div id="account">
<div id="info">
<div id="yourAccount">
YOUR ACCOUNT</div>
<hr style="height:1px;border:none;color:#049e84;background-color:#049e84;" />
<p class="title">Username:</p>
<p id="username" class="details"></p>
<p class="title">Name:</p>
<p id="name" class="details"></p>
<p class="title">Email:</p>
<p id="email" class="details"></p>
<p class="title">Phone:</p>
<p id="phone" class="details"></p>
<p class="title">Address:</p>
<p id="address" class="details"></p>
<p class="title">Your Tickets:</p>
<p id="tickets" class="details"></p>
<p id="valid"></p>
<hr style="height:1px;border:none;color:#049e84;background-color:#049e84;" />
</div>
<div id="operativeButtons">
<p id="home">Home</p>
<p id="logout">Logout</p>
<p id="deleteaccount">Delete Account</p>
<p id="warning">WARNING:</p>
<p id="warningmessage">Deleting your account will entirely erase all your data from our database. By
clicking, you acknowledge this. <br> All tickets will be erased</p>
</div>
</div>
</div>
Please note in the code above that the html and body tags are closed later after the PHP, this isn't the issue. :)
any help would be greatly appreciated, I am completely perplexed! That being said though, I'm also very tired.

Looks like you lack a clear of the floats, that's why the parent element (#account) does not get the expected height.
You can use a clear fix like this:
#account:after {
content: "";
display: table;
clear: both;
}
more info here:
https://css-tricks.com/snippets/css/clear-fix/
Another dirty way to do it is adding <br clear="all"/>. before closing #account.

Related

I have a issue about the margin and display in my assignment

I am confused by the margin when I write the code:
Section {
background-color: #FFFFFF;
width="100%";
}
p1 {
font-family: Roboto;
font-size: 22px;
font-height: 1px;
margin-top: 45px;
margin-left: 165px;
}
p2 {
font-family: Roboto;
font-size: 22px;
font-height: 1px;
margin-top: 10px;
margin-left: 165px;
}
<section>
<p class="p1"> Content 1 </p>
<p class="p2"> Content 2 </p>
</section>
However, when I don't add the display, the background in section will not cover all the content. when I add the display: inline-block, it will cover but it will have the same first situation when I change display:inline-block to display: inline or display:block. So everyone can explain me what is happening please?
Add overflow:auto or overflow:hidden or overflow:scroll.
section {
background-color: red;
width: 100%;
overflow:auto; // added
}
.p1 {
font-family: Roboto;
font-size: 22px;
margin-top: 45px;
margin-left: 165px;
}
.p2 {
font-family: Roboto;
font-size: 22px;
margin-top: 10px;
margin-left: 165px;
}
<section>
<p class="p1"> Content 1 </p>
<p class="p2"> Content 2 </p>
</section>
The only issue is with you misused the double quotes in the width property of your section CSS, also the class selectors in your css haven't started with ".", so just update your css it will definately work.

How can I move the text position downwards using CSS?

I want to move the text "Hi" downwards because the PNG file makes it separate too much from the rest of the text.
body {
background-color: #1d1d1d;
}
.content {
padding-top: 200px;
padding-bottom: 200px;
padding-left: 100px
}
.content > h1 {
color: white;
font-family: 'Montserrat', sans-serif;
font-size: 30px;
}
<article id="main" class="content">
<h1>Hi, <br/>
I'm <img src="../Sources/Untitled-2.png" alt="V">ictor,
<br/> just another Video Editor.
</h1>
</article>
You can add a <p> tag to your "Hi," to be able to refer to that part of the text only. In this case, I added a class as well <p class="hiText">Hi, </p>.
Then in the CSS, I referred to the hiText class and applied the following properties:
position: absolute; This sets the position of the text to absolute.
padding-top: -40px; This moves the text downwards. You can change 40px to any desired number and/or measurement unit.
Hope this answers your question!
body {
background-color: #1d1d1d;
}
.content {
padding-top: 200px;
padding-bottom: 200px;
padding-left: 100px
}
.content > h1 {
color: white;
font-family: 'Montserrat', sans-serif;
font-size: 30px;
}
.hiText {
position: absolute;
padding-top: -40px;
}
<article id="main" class="content">
<h1><p class="hiText">Hi, </p><br/>
I'm <img src="../Sources/Untitled-2.png" alt="V">ictor,
<br/> just another Video Editor.
</h1>
</article>
I put "Hi," in a <p class="hiText"> </p> and then used
.hiText {
position: relative;
top: 38px;
}

HTML CSS Banner Alignment

Can someone please help me out why my "desc" content is not right under my title in the banner? I have posted my CSS and HTML code. I have also posted the photo of how the outcome looks.
#bannerBottom {
border: 5px #0087dd solid;
margin-top: 30px;
margin-bottom: 50px;
}
#bannerImg {
width: 150px;
margin-top: 7px;
margin-left: 10px;
display: inline-block;
}
#bannerContent {
display: inline-block;
vertical-align: top;
margin-left: 20px;
}
#bannerContent>span {
font-size: 20px;
font-weight: bold;
font-family: arial;
color: steelblue;
display: inline-block;
}
#desc {
font-family: arial;
display: inline-block;
margin-left: 190px;
}
<div id="bannerBottom">
<img id="bannerImg" src="http://www.placehold.it/100x100">
<p id="bannerContent">
<span>The Big 3 - HTML, CSS, JavaScript</span>
</p>
<p id="desc">While the server can process information in many different languages, the file that they serve to the client are always going to be some combination of HTML, CSS, and JavaScript!<br>Learn more about the Big 3 here!</p>
</div>
You can float your image left instead of making it an inline-block element. Also there'd be no need to make the paragraph an inline-block either.
#bannerBottom {
border: 5px #0087dd solid;
margin-top: 30px;
margin-bottom: 50px;
}
#bannerImg {
width: 150px;
margin-top: 7px;
margin-left: 10px;
float: left;
}
#bannerContent {
display: inline-block;
vertical-align: top;
margin-left: 20px;
}
#bannerContent>span {
font-size: 20px;
font-weight: bold;
font-family: arial;
color: steelblue;
display: inline-block;
}
#desc {
font-family: arial;
margin-left: 190px;
}
<div id="bannerBottom">
<img id="bannerImg" src="http://www.placehold.it/100x100">
<p id="bannerContent">
<span>The Big 3 - HTML, CSS, JavaScript</span>
</p>
<p id="desc">While the server can process information in many different languages, the file that they serve to the client are always going to be some combination of HTML, CSS, and JavaScript!<br>Learn more about the Big 3 here!</p>
</div>
Surely it is because you have:
#desc {
margin-left: 190px;
}
... which means the box isn't fitting under the title, so it is getting shunted underneath. Either way, float the image left and don't have margin-left.
try this:
<div id="bannerBottom">
<div class="container-banner-img">
<img id="bannerImg" src="http://www.placehold.it/100x100">
</div>
<div class="container-banner-content">
<p id="bannerContent">
<span>The Big 3 - HTML, CSS, JavaScript</span>
</p>
<p id="desc">While the server can process information in many different languages, the file that they serve to the client are always going to be some combination of HTML, CSS, and JavaScript!<br>Learn more about the Big 3 here!
</p>
</div>
</div>
CSS
#bannerBottom {
border: 5px #0087dd solid;
margin-top: 30px;
margin-bottom: 50px;
}
#bannerImg {
width: 150px;
margin-top: 7px;
margin-left: 10px;
display: inline-block;
}
#bannerContent {
display: inline-block;
vertical-align: top;
margin-left: 20px;
}
#bannerContent>span {
font-size: 20px;
font-weight: bold;
font-family: arial;
color: steelblue;
display: inline-block;
}
#desc {
font-family: arial;
display: inline-block;
margin-left: 190px;
}
.container-banner-img {
float: left; /* <- pay attention on this line */
width:25%;
}
.container-banner-content{
width: 70%;
}
}
If you don't want to go the flexbox route you can float the image and keep your heading and description block level.
I took a few liberties with the markup and CSS selectors, changing them from IDs to classes and other improvements to streamline everything.
.entry {
font-family: Arial, sans-serif;
border: 5px solid #0087dd;
margin: 30px 0;
}
.entry-img {
float: left;
max-width: 150px;
margin: 10px;
}
.entry-title {
font-size: 20px;
color: steelblue;
}
.entry-desc {
margin: 10px;
}
<div class="entry">
<img class="entry-img" src="http://www.placehold.it/100x100">
<h2 class="entry-title">The Big 3 - HTML, CSS, JavaScript</h2>
<p class="entry-desc">While the server can process information in many different languages, the file that they serve to the client are always going to be some combination of HTML, CSS, and JavaScript!<br>Learn more about the Big 3 here!</p>
</div>

having trouble centering my section element

This is probably a silly question but I can't seem to figure out how to auto center my section
live demo: http://iam.colum.edu/students/jordan.max/algorerhythm/index.html#
I have tried to add
margin: 0 auto;
to my div#content, with no luck.
The only way I was able to get it be centered was manually entering in
margin-left: xxpx
but I want it to be centered based on what content is in it. Any thoughts? Thanks in advance.
Rest of CSS
body
{
background: #C1CDC1;
}
h1
{
}
h2
{
margin-top: -40px;
margin-left: 120px;
}
h1.mainT
{
width: 590px;
font-family: 'Montserrat', sans-serif;
margin-left: 10px;
font-size: 2.5em;
}
h2.subT
{
width: 130px;
font-family: 'Open Sans Condensed', sans-serif;
}
h3
{
display: inline-block;
font-family: 'Open Sans Condensed', sans-serif;
}
footer
{
color: #FCFCFC;
text-align: center;
font-family: 'Montserrat', sans-serif;
font-size: .85em;
}
section#nav
{
width: auto;
margin-left: 550px;
margin-top: -80px;
padding: 5px;
word-spacing: 80px;
}
div#navContainer
{
height: 100px;
background: #FCFCFC; /* grey99*/
box-shadow: 2px 3px 5px #333;
}
div#content
{
height: 100px;
width: auto;
background: #FCFCFC; /* grey99*/
box-shadow: 2px 3px 5px #333;
display: inline-block;
}
section#contentContainer
{
float: none;
padding-top: 20px;
margin: 0 auto;
}
HTML
<script>
$(document).ready(function () {
$('section#contentContainer').hide();
var $as = $('a.contentDown').click(function () {
//show back button, move it from left +300
$('section').show();
}); //closes click for contentDown
}); //closes ready
</script>
</head>
<body>
<div id="navContainer">
<h1 class="mainT"> Al Gore Rhythm Labs </h1>
<h2 class="subT"> Chicago, IL </h2>
<section id="nav">
<h3> Assignments </h3>
<h3> Writings </h3>
<h3> Presentations </h3>
</section>
</div>
<section id="contentContainer">
<div id="content">
<p> hello motto
</p>
</div>
</section>
</body>
<footer>
<p> Jordan Max 2014</p>
</footer>
</html>
Maybe this is the solution (don't forget to remove style="display: none;" for your section#contentContainer)
Result:
Add text-align center; to your section#contentContainer
section#contentContainer
{
float: none;
padding-top: 20px;
margin: 0 auto;
text-align: center;
}
Good Luck!!
Add 'align="center"' to your section element.
As follows:
<section id="contentContainer" align="center">
This is not the preferred way but if you want to do it only in CSS, you would need to do 'text-align: center' on the element to center align it's internal 'inline-block' element.
CSS: text-align: center

How do you align text vertically inside a container regardless of # of links inside them?

I need some assistance and I've tried almost everything I know. What I am trying to do (and it doesn't matter if I have to use tables on order to achieve this)
http:// img602.imageshack.us/img602/8769/verticalcentering .jpg
I've looked online and tried out several examples but they all seem to blow up or not align properly in IE.
What I need (if its possible, I don't even know anymore) is to have text links that will align vertically within the container its in regardless of whether there is only one link present, or four.
What's been happening is that when I set the margin to 50% it centers fine if there is only one link there, but the remainder will fall below it no longer centering the links within the container.
The actual thing I am working on is this:
I have a header title above that stretches across the container. The next row I have an image on the left that is 150px by 150px - and next to that I have another container that has a height of 150px as well as this is the maximum height of this container - inside this container is where I would like my links to hang out vertically centered.
Is this even possible? or is it a pipe dream to think it will work in IE and is cross browser compliant?
It doesn't matter anymore if I have to resort to tables and css to achieve this... I just need some assistance with it as I have never had to vertically center anything depending on its content before and I just can't wrap my head around how to achieve this effect.
Any help would be greatly appreciated :) Thanks in advance!
HERE IS THE CSS AND HTML BELOW
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Link Module</title>
<style type="text/css">
<!--
.wrapper { height: 210px; width: 538px; background-color: #FFCCFF; }
.header { height: 47px; border-bottom: thin dotted #666; }
.txt-style {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
line-height: normal;
font-weight: bold;
color: #666666;
text-decoration: none;
text-align: left;
vertical-align: middle;
white-space: normal;
display: block;
}
.cos-sl-txt-cntr-two {
height: 150px;
}
.cos-sl-txt-cntr-two ul {
height: 150px;
margin-top: auto;
margin-bottom: auto;
}
.cos-sl-txt-cntr-two li {
margin-top: 50%;
margin-bottom: auto;
}
cos-sl-img-two {
width: 150px;
height: 150px;
background-color: #FF0033;
}
.learn-txt, .leader-txt {
color: #FF6666;
font-family: "Arial", Helvetica, sans-serif;
text-transform: uppercase;
font-size: 12px;
margin: 0;
padding-top: 2px;
padding-left: 10px;
letter-spacing: .75px;
}
.leader-txt {
color: #fff;
font-size: 23px;
font-weight: bold;
padding-top: 0px;
line-height: 24px;
letter-spacing: -0.25px;
}
.img-ctnr, .img-ctnr-two {
width: 150px;
height: 150px;
float: left;
padding-left: 12px;
}
/* IMAGE LOCATION */
.img-two {
width: 150px;
height: 150px;
display: block;
background-color: #FF99CC;
border: solid 3px #CCC;
}
.txt-cntr, .txt-cntr-two {
width: 406px;
height: 126px;
float: left;
}
.txt-cntr-two {
width: 250px;
height: 150px;
padding-left: 50px;
background-color:#CC99CC;
}
.txt-pos {
float: left;
width: 100px;
height: 50px;
padding-left: 20px;
}
/* NAME TEXT/TITLE TEXT */
.name-txt, .info-txt, .name-txt-title, .info-txt-link {
font-family: "Arial", Helvetica, sans-serif;
font-size: 13px;
color: #003466;
margin: 0;
padding-top: 18px;
padding-left: 13px;
}
.sl-name-txt-title {
color: #666;
font-size: 10px;
font-weight: bold;
}
/* INFO TEXT/TEXT LINK OVER-RIDE */
.info-txt, .info-txt-link {
padding-top: 0;
color: #333;
font-size: 12px;
line-height: 1.1;
}
.info-txt-link a {
color: #003466;
text-decoration: none;
}
/* Hover State for the web links */
.info-txt-link a:hover {
color: #ED1B24;
text-decoration: none;
}
-->
</style>
</head>
<body>
<div class="wrapper">
<!--CONTAINER HOLDING THE HEADER ELEMENTS-->
<div class="header">
<p class="learn-txt">Title</p>
<p class="leader-txt">Subtitle</p>
</div>
<div class="img-ctnr-two">
<div class="img-two">
</div>
</div>
<div class="txt-pos">
<p class="name-txt-title">Canada</p>
<p class="info-txt-link">www.mylinkhere.com</p>
</div>
</div>
</body>
</html>
.outer {
border: 1px solid red;
line-height: 5em;
}
.outer .inner {
display: inline-block;
vertical-align: middle;
line-height: 1.2em;
}
<div class="outer">
<div class="inner">
ABC
</div>
</div>
<div class="outer">
<div class="inner">
ABC<br>ABC
</div>
</div>
<div class="outer">
<div class="inner">
ABC<br>ABC<br>ABC
</div>
</div>