I'm designing a fairly simple web site but as I don't have much experience I have a very simple question.
I've done the layout in a way that displays all the necessary information without the need of scrolling down. But for some reason it's there.
The site's css is as following:
#charset "utf-8";
/* CSS Document */
html {height:100%;width:100%; margin:0;}
body{
height:65%;
font-size:100%;
font-family:Calibri;
background-image:url(/images/gradient.png);
background-repeat:repeat-x;
background-color:#FFF0;
color:#00080;
margin-left:15%;
margin-top:3%;
margin-right:15%;
width:65%;
}
#banner {
height:40%;
background: url(/images/banner.jpg) right scroll no-repeat;
}
#left_container{
width:20%;
height:80%;
}
#left_container img{
width:100%;
}
a{
text-decoration:none;
color:#FFF;
border:none;
}
#menu{
width:100%;
height:85%;
font-size:120%;
}
#menu td{
background:#999;
color:#FFF;
padding:4%;
}
#menu tr td a:hover{
background:#CCC;
color:#333;
}
#right_container{
width:75%;
height:auto;
position:relative;
left:+26%;
top:-80%;
}
#right_container h2{
font-size:300%;
}
#right_container h3{
font-size:200%;
}
But the web site looks like this (and the scroll appears when I set the right_container h2 title (home) size in the css bigger than 190%....but I need it to be as I set...or it will be to small).How can I remove the scroll bar?
image -> http://i29.tinypic.com/hx3uy8.jpg
You can control the appearance of scrollbars in CSS by using the Overflow property. So you could try adding overflow: hidden to your BODY CSS declaration and see if that helps.
Related
I set up some CSS styles for a HTML page and all was working as expected. I then edited the CSS (minimally) and suddenly the layout breaks. I've got a copy of the original (working) CSS so I could just go with that. But I wanted to sort out what I did wrong.
So, I've spent a few hours going over the faulty CSS but I just cannot find where it is incorrect. Hoping someone can point out the mistake.
In both cases the HTML is the same.
I've created 2 CodePens, one with working HTML/CSS, the other with same HTML and faulty CSS. The problem is in the footer area. With the faulty CSS, the 'bottom bar' rides up into the main footer above. However, I think I've cleared floats correctly.
Below is what I think is the faulty section of CSS (but it will make more sense to view it along with HTML - see CodePen links further below):
footer{
font-family: 'Open Sans', sans-serif;
margin-top:200px;
border-top:6px solid rgba(246, 246, 246, 0.8);
background-repeat:repeat-x;
background-position:left bottom;
background-size:contain;
background-color:#b8b8b8;
}
.footer-column-container{
width:95%;
max-width:1200px;
list-style-type:none;
margin:0 auto;
padding:25px 0;
}
.footer-column-container li{
float:left;
padding:20px 5px;
width:25%;
box-sizing:border-box;
}
.footer-column-container ul {
list-style-type:none;
}
.footer-links{
height:250px;
}
.footer-links li{
float:none;
display:block;
line-height:12px;
padding:8px 0;
width:100%;
}
.footer-column h4{
color:#fff;
font-size:16px;
font-weight:bold;
margin-bottom:10px;
}
.footer-column a:link{
font-size:14px;
text-decoration:none;
color:#fff;
}
#bottom-bar-container{
background-color:#000;
border-top:1px solid #393939;
padding:20px 0;
}
#bottom-bar{
font-size:12px;
margin:0 auto;
width:95%;
text-align:center;
color:#fff;
}
There's a fair bit of code so, rather than place it all here, I'll list links to CodePens:
Link to working HTML/CSS: http://codepen.io/Ben10/pen/VjBgyB
Link to working HTML / Faulty CSS: http://codepen.io/Ben10/pen/pbkYAd
Many thanks if you can help me.
you have a floating issues so use clear:both; on #bottom-bar-container
#bottom-bar-container {
background-color: #000;
border-top: 1px solid #393939;
clear: both;
padding: 20px 0;
}
or
use overflow: hidden; to .footer-column-container
I hope that will be helpful to achieve you goal
Add below overflow:hidden; into your .footer-column-container
.footer-column-container{
width:95%;
max-width:1200px;
list-style-type:none;
margin:0 auto;
padding:25px 0;
overflow:hidden; /*Add this*/
}
Add the <div style="clear:both;"></div> before <div id="bottom-bar-container"></div>
Since you are using floating elements inside footer-column-container, its height won't be set automatically. You need to use overflow:hidden in .footer-column-container CSS.
That is
.footer-column-container{
width:95%;
overflow:hidden; /*This property is missing*/
max-width:1200px;
list-style-type:none;
margin:0 auto;
padding:25px 0;
}
So that the div will accommodate its floating child elements , ie the li elements inside footer-column-container.
You have overflow:hidden property set in your working CSS. In the faulty code, that property is missing. It is simply the reason why it has messed up.
Its only need to clear div. I check your whole code you need to clear your div. Here updated fiddle.
Here I change your code, Have look..
footer{
font-family: 'Open Sans', sans-serif;
margin-top:200px;
border-top:6px solid rgba(246, 246, 246, 0.8);
background-repeat:repeat-x;
background-position:left bottom;
background-size:contain;
background-color:#b8b8b8;
width:100%;
float:left;
clear:both;
}
.footer-column-container{
width:95%;
max-width:1200px;
list-style-type:none;
margin:0 auto;
padding:25px 0;
display:inline-block
}
For more details for clearing div why and how please go here.
learnlayout.com
quirksmode.org
css-tricks.com
I hope it will help you :)
The top part of the five links on the right aren't clickable. How can I get the link to be active throughout the entire button?
Also, how would I make it so that when I hover over the links, the background color still changes as it currently does but has an opacity:0.5. Whenever I try this the background color as well as the words turn transparent.
One more thing. If I re-size my browser the navbar moves around and looks terrible. How can I keep the navbar in place as I re-size the browser?
Here's the JSFiddle link
HTML Code
<!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>Me</title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Montserrat:700' rel='stylesheet' type='text/css'>
</head>
<body>
<section class="main_front">
<nav id="nav_container">
<div class="logo"><img src="../images/logo.png" height="65px" /></div><!--end of logo-->
<ul class="right_links">
<li class="nav_li">Goals</li>
<li class="nav_li">School Site</li>
<li class="nav_li">Web Design</li>
<li class="nav_li">Summer</li>
<li class="nav_li">Schedule</li>
</ul><!--end of right_links-->
</nav><!--end of nav_container-->
</section><!--end of main_front-->
<section class="footer">
<div class="phonenumber">
<b>Contact:</b> 239-XXX-XXXX
</div><!--end of phonenumber-->
<div id="email">
adesign#email.com
</div><!--end of email-->
<div class="address">
1234 Web Design Ave.
</div><!--end of address-->
</section><!--end of footer-->
</body>
</html>
CSS Code
#charset "utf-8";
/* CSS Document */
body {
margin:0;
margin:none;
}
.logo {
float:left;
margin-top:5px;
}
.main_front {
width:100%;
height:90vh;
background-color:#A9D2F1;
}
/* .nav_links {
width:1600px;
height:100px;
margin:auto;
color:white;
} */
.nav_li {
float:right;
margin-right:20px;
}
#nav_container {
width:100%;
height:79px;
/*background-color:#82B5E8;*/
background-image:url(../images/nav_container_bg.png);
}
.right_links {
width:70%;
float:right;
list-style-type:none;
text-align:center;
}
.right_links a {
display:inline-block;
list-style-type:none;
text-decoration:none;
color:white;
font-size:17px;
margin-top:15px;
font-family:Montserrat, "Arial Black", Gadget, sans-serif;
}
.right_links li {
width:130px;
height:40px;
line-height:10px;
text-align:center;
border-radius:15px;
transition:all 0.5s;
-moz-transition:all 0.5s;
-webkit-transition:all 0.5s;
-ms-transition:all 0.5s;
}
.right_links li a {
display:block;
width:130px;
height:40px;
}
.right_links li:hover {
background-color:#166083;
}
.phonenumber {
font-size:26px;
margin-left:15px;
float:left;
}
.address {
font-size:26px;
margin-left:75%;
}
#email {
font-size:26px;
float:left;
margin-left:-295px;
margin-top:40px;
}
.footer {
width:100%;
height:10vh;
background-color:#8FC6ED;
}
change your CSS to this:
/* CSS Document */
body {
margin:0;
margin:none;
}
.logo {
float:left;
margin-top:5px;
}
.main_front {
width:100%;
height:90vh;
background-color:#A9D2F1;
}
/* .nav_links {
width:1600px;
height:100px;
margin:auto;
color:white;
} */
.nav_li {
float:right;
margin-right:20px;
}
#nav_container {
width:100%;
height:79px;
/*background-color:#82B5E8;*/
background-image:url(../images/nav_container_bg.png);
}
.right_links {
width:70%;
float:right;
list-style-type:none;
text-align:center;
}
.right_links a {
display:block;
list-style-type:none;
text-decoration:none;
color:white;
font-size:17px;
margin-top:0px; height:30px; padding-top:15px;
font-family:Montserrat, "Arial Black", Gadget, sans-serif;
}
.right_links li {
width:130px;
height:40px;
line-height:10px;
text-align:center;
border-radius:15px;
transition:all 0.5s;
-moz-transition:all 0.5s;
-webkit-transition:all 0.5s;
-ms-transition:all 0.5s;
}
.right_links li a {
display:block;
width:130px;
height:40px;
}
.right_links li:hover {
background-color:rgba(22,96,131,0.5);
}
.phonenumber {
font-size:26px;
margin-left:15px;
float:left;
}
.address {
font-size:26px;
margin-left:75%;
}
#email {
font-size:26px;
float:left;
margin-left:-295px;
margin-top:40px;
}
.footer {
width:100%;
height:10vh;
background-color:#8FC6ED;
}
About your last question, it all depends on what you need. If you want to make it responsive, the size of the nav will vary, hence the menu elements will re-locate, this requires a decision on what do you want to do depending on which size is shown (you can do nothing as well, as in no resizing)
You are using margin-top:15px to move the text down on the button. Change this to padding-top and the entire button will be clickable. This is because padding is on the inside of the a tag, and so expands the size of the a tag (which is your clickable link).
You have stumbled onto a problem that bothers a lot of us. When you have text within an element, it is tricky to apply opacity to the element but not to the text within. However, there are workarounds that workgreat. Here are a couple of posts:
http://css-tricks.com/non-transparent-elements-inside-transparent-elements/
CSS - Apply Opacity to Element but NOT To Text Within The Element
There are two ways to specify the location/size of elements on your page: fixed px/em or percentages. Fixed sizes do not re-size, but percentages do. Therefore, instead of this:
Do this:
<div style="height:10%;width:15%;"></div>
As the window size changes, so will the width/height of the div.
Two downsides to this approach:
a. You probably can't do this with just the navbar -- you may have to refactor your page to use percentages in most places;
b. Large monitors will have larger elements than smaller monitors -- but usually, this is a good thing.
What most folks do when switching to percentages is to set the outer page boundaries (the "wrap" or "container" or whatever is your top-level level div beneath body) in pixels -- and then use percentages for all else underneath. Okay, rarely all -- it is okay to mix percents and pixels/ems (of course, not in the same element ). Usually, there are some divs (buttons or shapes or whatever) that will remain fixed size regardless the size of the monitor/window.
A couple of references on this one:
http://kyleschaeffer.com/development/css-font-size-em-vs-px-vs-pt-vs/
Which is better to use in CSS, percentage or pixels?
I am designing a website, and I want to have a nav bar that resizes to the size of the screen.
This is what I have right now for html:
<nav>
Item 1
Item 2
Item 3
Item 4
</nav>
and css:
nav a {
text-decoration:none;
font-size:2em;
color:#fff;
width:25%;
display:block;
float:left;
background-color:#000;
text-align:center;
}
http://jsfiddle.net/GJVqR/
This works fine until the screen gets down to a certain size at which point I want the menu items to stack on top of each other.
Is there a way to do this without resorting to JS?
EDIT: After receiving a few answers I feel I need to clarify: http://i.stack.imgur.com/9ID5N.png
This is what I am looking for when the screen gets too small.
Set the
min-width
CSS property:
nav a {
min-width: 100px;
text-decoration:none;
font-size:2em;
color:#fff;
width:25%;
display:block;
float:left;
background-color:#000;
text-align:center;
}
You may use min-width instead width, and have them float or not :
http://jsfiddle.net/GJVqR/2/ http://jsfiddle.net/GJVqR/3/
nav a {
text-decoration:none;
font-size:2em;
color:#fff;
min-width:25%;
display:inline-block;
float:left;
background-color:#000;
text-align:center;
}
I found a solution using the #media css
#media (max-width:21.5em){
nav a {
width:100%
}
}
http://jsfiddle.net/GJVqR/4/
My final is to recreate a basic html page with my own css like csszengarden.com.
I made a simple one page deal at http://randallmiller.pcriot.com/72bclass/final72b/index.html.
However a few of my links are not clickable. Here is the css for the site. Any help would be greatly appreciated!
EDIT: I fixed the unclickable part with z-index:1, I think because of the padding on linkblock2. However, now my a:hover to turn them grey is only working for a few.
html{
height:100%;
}
body{
background:#000000;
}
h3{
margin-top:0;
}
h3 span{
color:white;
display:block;
}
.pgtitle1{
word-spacing:10px;
padding-top:25px;
margin-left:125px;
font:1.5em "Trebuchet MS", Arial, Helvetica, sans-serif;
}
.pgtitle2{
padding-top:10px;
margin-left:275px;
font:bold .7em "Comic Sans MS", cursive;
letter-spacing:2px;
}
div#linkblock1{
position:absolute;
top:200px;
padding-left:25%;
}
div#linkblock2{
position:absolute;
top:200px;
padding-left:67.5%;
}
div a{
border-bottom:solid 1px white;
text-decoration:none;
text-align:center;
padding:5px;
display:block;
width:90px;
}
div a:hover{
color:rgb(200,200,200);
}
div a:visited{
color:blue;
}
div#fg_img{
height:323px;
background:url(bg.jpg) no-repeat center;
margin-top:50px;
line-height:999;
overflow:hidden;
}
h2{
font-size:.75em;
color:#FFF;
position:absolute;
top:10px;
left:60px;
}
You've covered up some of your links with #fg_img. Set some z-indexes.
Your divs are overlapping each other in many weird ways, the position:absolute on the div with the right links "linkblock2" is overlapping the links on the left.
You should really remove the position:absolute and use float on the divs, and you wouldn't run into that problem.
Not sure if it's an option or not, but check out a CSS Grid system if you can use it on your assignment.
CSS stylesheet
div.Header
{
background-color:#999999;
text-transform:capitalize;
text-align:center;
}
div.leftdiv
{
float:left;
height:200px;
width:15%;
position:fixed;
background-color:#FFFF66;
text-transform:uppercase;
text-align:justify;
}
div.rightdiv
{ margin-left:15px;
margin-top:25px;
float:left;
position:fixed;
background-color:#FFFF99;
width:50%
height:200px;
left: 438px;
top: 39px;
}
div.footer
{
clear:both;
margin-left:20px;
margin-top:20px;
margin-right:20px;
margin-right:20px;
padding-bottom:10px;
padding-left:10px;
padding-right:10px;
padding-right:10px;
border-color:#000066
border:thick;
text-align:center;
background-color:#FFCCFF;
}
Upon further review, it looks like you have some fixed position attributes that are tripping you up. If you remove them, everything displays fine:
http://jsbin.com/emona3/3/edit
put float:left for footer its essential to move footer after all other div .