Trouble with CSS format [closed] - html

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I cant for the life of me find out whats wrong with the CSS code, I cant get the font in main <p> to be 20px and can't properly center the address in the footer. I am only allowed to edit css file.
Html file:
http://www.mediafire.com/view/68bcokhw6tb086g/redball.htm
CSS file:
http://www.mediafire.com/view/9rk9dracsz47sn7/pizza.css
CSS code:
/*
New Perspectives on HTML and CSS
Tutorial 4
Case Problem 2
Pizza Style Sheet
Author: Joesph Aguilar
Date: 01/31/2014
Filename: pizza.css
Supporting Files:
*/
/* Display Block Elements */
header, section, aside, footer, nav{
display: block;
}
/* Padding and Margin Style */
*{
padding: 0px;
margin: 0px;
}
/* Body Style */
body{
background-color: red;
font-family: Verdana, Geneva, sans-serif;
}
/* Container Style */
#container{
width: 1000px;
margin-top: 0px;
margin-bottom: 0px;
margin-left: auto;
margin-right: auto;
border-left: 1px solid black;
border-right: 1px solid black;
background: white url('redbar.png') repeat-y left top;
}
/*Header Style */
header{
background-color: white;
height: 100px;
}
/* Horizontal Nav Style */
nav.horizontal{
background-color: white;
height: 70px;
width: 100%;
}
nav.horizontal li{
background-color: white;
font-size: 16px;
height: 50px;
line-height: 50px;
width: 180px;
display: block;
float: left;
margin-left: 5px;
margin-right: 5px;
text-align: center;
}
nav.horizontal li a{
display: block;
background-color: red;
color: white;
border-radius: 30px / 25px;
-moz-border-radius: 30px / 25px;
-webkit-border-radius: 30px / 25px;
text-decoration: none;
}
nav.horizontal li a:hover{
background-color: (255, 101, 101);
color: black;
}
/* Vertical Nav Style */
nav.vertical{
clear: left;
float: left;
width: 200px;
}
nav.vertical li{
list-style-type: none;
text-indent: 20px;
margin-top: 20px;
margin-bottom: 20px;
}
nav.vertical li a{
color: white;
text-decoration: none;
}
nav.vertical li a:hover{
color: black;
}
/* Section Style */
#main{
background-color: rgb(255, 211, 211);
float: left;
width: 600px;
}
#main > p {
font-size: 20px;
margin: 15px;
}
#main img{
float: right;
margin: 15px;
width: 350px;
border-bottom-left-radius: 350px;
-moz-border-radius-bottomleft: 350px;
-webkit-bottom-left-radius: 350px;
}
/* Coupon Style */
#main div.coupon{
border: 5px;
border-style: dashed;
float: left;
width: 170px;
height: 150px;
margin-top: 20px;
margin-bottom: 20px;
margin-left: 10px;
margin-right: 10px;
background: white url('slice.png') no-repeat right bottom;
}
#main div.coupon h1{
color: white;
background: rgb(192, 0, 0);
font-size: 16px;
letter-spacing: 2px;
text-align: center;
height: 25px;
font-variant: small-caps;
}
#main div.coupon p{
font-size: 14px;
text-align: center;
margin: 5px;
}
/* Aside Style */
aside{
float: left;
width: 200px;
}
aside h1{
color: rgb(192, 0, 0);
font-size: 20px;
letter-spacing: 2px;
font-weight: normal;
text-align: center;
}
aside li{
background-color: rgb(255, 135, 135);
border-radius: 5px;
list-style-type: none;
margin: 10px;
padding: 5px;
}
/*Footer Style*/
footer{
clear: left;
margin-left: 200px;
}
footer address{
border-top-style: 1px solid red top;
color: red;
font-size: 10px;
font-style: normal;
text-align: center;
margin-top: 25px;
padding-bottom: 20px;
}

The address is centered in the footer. Your problem is that you want the address centered on section#main, and the footer isn't in the section#main, it's in div#container, resulting in an address centered to the whole container.
However, since your aside has a static width of 200px, we can add that as a margin into footer>address, so that it centers the content accordingly.
So, we want on footer address is:
margin-right:200px;
but since we already have
margin-top:25px;
we can just delete that margin-top line and say both with:
margin:25px 200px 0 0;
which is shorthand for margin top 25px right 200px bottom 0 left 0.
Finally, the correct way to post this would be on JSFiddle, it's super easy to figure out, and I put my solution for your problem here:
http://jsfiddle.net/R8Hsv/

All about your font size seems fine, at least I can change it. How do you expect 20px to be?
Had to set a width for your footer, to the same as the main.
footer address{
border-top-style: 1px solid red top;
color: red;
font-size: 10px;
font-style: normal;
text-align: center;
margin-top: 25px;
padding-bottom: 20px;
width:600px;
}
JSFIDDLE: http://jsfiddle.net/42h96/1/

Related

How to make sure that an element is not covered by another (CSS)?

I am new at web developing.
Trying to make site logo look good.
Have two elements, one of them is covered by another so user can't click on first of them.
Help me please making them one above another.
How can I do this stuff using only CSS?
Codepen: https://codepen.io/h071/pen/YOeXaw
This is HTML part:
<header>
<link rel="stylesheet" type="text/css" href="/a/www/css/style_header.css">
<nav class="container-fluid">
<a class="logo" href="/a/www/index.php">
<span>Sitename</span>
</a>
<p id="reg-auth-title">Login|Registration</p>
And this is CSS:
header {
width: 100%;
height: 5em;
position: relative;
}
nav {
width: 100%;
}
.logo {
display: block;
float: left;
position: absolute;
margin-top: 0.4em;
margin-left: 1em;
}
.logo span {
font-size: 5em;
color: black;
display: inline-block;
/*line-height: 1em;*/
}
#reg-auth-title {
/* width: 20%; */
padding: 0;
margin: 0;
float: left;
}
#reg-auth-title a.top-auth {
font: bold 15px sans-serif;
text-decoration: none;
padding-left: 8px;
padding-right: 8px;
padding-top: 4px;
padding-bottom: 4px;
border: 1px solid red;
border-radius: 5px; /*other browsers*/
-webkit-border-radius: 5px; /*safari*/
-moz-border-radius: 5px;
cursor: pointer;
color: black;
}
#reg-auth-title a.top-auth:hover {
text-decoration: none;
}
#reg-auth-title a {
font: 15px sans-serif;
font-weight: bold;
text-decoration: none;
color: #58ACFA;
margin-left: 1em;
border-bottom-style: dashed;
border-bottom-color: #58ACFA;
border-bottom-width: 1px;
}
You need to put your link above logo using z-index.
#reg-auth-title {
z-index: 10;
position: relative; // z-index works only with non-static positioned elements
}

Elements overflowing on right side for some time?

Im working on a gadget site.So i have to display 10 items on page.
My problem is whenever my page loads,item 2 floats on the right side of item 1 for some time then it appears correctly on left side.It happens for the rest of the items.I want all items to left at once.
See demo so you will get idea what im saying.
Demo here.
Also attached my CSS.
What are some corrections i should make?
.article-number{
border: 1px solid;
float: left;
width: 35px;
height: 40px;
padding-left: 15px;
padding-top: 5px;
font-size: 24px;
font-weight: 700;
background: #000000;
color: #ffffff;
overflow: hidden;
}
.article-item-title{
border: 1px solid;
width: auto;
height: 40px;
overflow: hidden;
background: #000000;
color: #ffffff;
text-align: left;
padding-left: 25px;
padding-top: 5px;
font-size: 24px;
font-weight: 700;
}
.article_media{
float: left;
margin-top: 25px;
}
.article-container{
border: 1px dotted #ccc;
height: 170px;
width: 270px;
float: right;
margin-top: 25px;
margin-bottom: 30px;
margin-left: 10px;
}
.specification{
margin-top: 7px;
margin-left: 30px;
border-radius: 40px;
border: none;
width: 220px;
text-align: center;
background: #ff3800;
color: #ffffff;
height: 35px;
padding-top: 7px;
font-weight: 700;
font-family: 'Ubuntu', sans-serif;
font-size: 17px;
}
.specification a{
color: #ffffff;
}
#article-flipkart-icon{
margin-left: 40px;
margin-top: 10px;
float: left;
}
.affiliate-link{
width: 145px;
float: left;
margin-top: 10px;
height: 35px;
padding-left: 15px;
padding-top: 5px;
border-top-right-radius: 40px;
border-bottom-right-radius: 40px;
background: #289dcc;
font-weight: 700;
}
.affiliate-link a{
color: #ffffff;
}
#article-amazon-icon{
float: left;
margin-left: 40px;
margin-top: 10px;
}
.article-wrapper{
margin-top: 50px;
}
.article-item-one,.article-item-two,.article-item-three,.article-item-four,.article-item-five,.article-item-six,.article-item-seven,.article-item-eight,.article-item-nine,.article-item-ten{
float: left;
margin-bottom: 35px;
}
.featured-image{
border: 1px dotted;
pointer-events: none;
}
This is happening because all images are rendering after some time. There can be multiple solutions to this problem.
1. You can set image width in pixels (300px in your case). - By this, right content will be at proper position until images appears.
2. You can use a very low-quality image for all item list as a placeholder and later replace image src with proper image URL. - By this, placeholder image will render quickly and it will occupy the required space until proper image appears.

HTML/CSS float: left; is not working properly

I'm currently reading Headfirst CSS/HTML and I'm having an issue with an example.
I'm attempting to float the body to the left of the sidebar using float:left; however it's not floating properly. I've been over the HTML and CSS an I can't quite see what's wrong.
This is what I want it to look like:
And the fiddle: https://jsfiddle.net/Taubin/7Lhz4wtd/
#main {
background: #efe5d0 url(images/background.gif) top left;
font-size: 105%;
padding: 15px;
margin: 0px 10px 10px 10px;
width: 420px;
float: left;
}
<div id="allcontent">
<div id="header">
</div>
<div id="sidebar">
<p class="beanheading">
Sidebar text
</p>
<p>
Sidebar text
</p>
</div>
<div id="main">
<h1>QUALITY COFFEE, QUALITY CAFFEINE</h1>
<p>
Main text
</p>
</div>
</div>
Any suggestions would be greatly appreciated.
First, it might be the issue that you are adding margin and paddings, which add size to the box even though the box has a width of 420px, you have to calculate margins and paddings to, or use * { box-sizing: border-box; }, which will calculate the width of that element as a sum of all the sizes (padding, margin, width) and not exceed the width.
Second, the order of the elements are important when floating, put main always on top of the sidebar, since elements start as top to bottom, when you float a top element, the bottom element if its wider, will collapse and align with the main box.
Screenshot for reference:
Here is the https://jsfiddle.net/bg2v0dqn/.
You shouldn't add a large gap with margin.
Here's what I changed:
#main {
background: #efe5d0 url(images/background.gif) top left;
font-size: 105%;
padding: 15px;
margin: 0px 10px 10px 10px;
width: 420px;
float: left;
}
#sidebar {
background: #efe5d0 url(images/background.gif) bottom right;
font-size: 105%;
padding: 15px;
margin: 0px 10px 10px 0;
width: 290px;
float: right;
}
#sidebar {
background: #efe5d0 url(images/background.gif) bottom right;
font-size: 105%;
padding: 15px;
margin: 0px 10px 10px 0px;
float: right;
width: 290px;
}
Try this CSS code
body {
background-color: #b5a789;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: small;
margin: 0px;
display: table;
}
#header {
background-color: #675c47;
margin: 10px;
height: 108px;
}
#main {
background: #efe5d0 url(images/background.gif) top left;
font-size: 105%;
padding: 15px;
margin: 0px 10px 10px 10px;
width: 420px;
display: table-cell;
}
#sidebar {
background: #efe5d0 url(images/background.gif) bottom right;
font-size: 105%;
padding: 15px;
margin: 0px 10px 10px 10px;
width: 300px;
display: table-cell;
float: right;
}
#footer {
background-color: #675c47;
color: #efe5d0;
text-align: center;
padding: 15px;
margin: 10px;
font-size: 90%;
clear: left;
}
h1 {
font-size: 120%;
color: #954b4b;
}
.slogan { color: #954b4b; }
.beanheading {
text-align: center;
line-height: 1.8em;
}
a:link {
color: #b76666;
text-decoration: none;
border-bottom: thin dotted #b76666;
}
a:visited {
color: #675c47;
text-decoration: none;
border-bottom: thin dotted #675c47;
}
#allcontent {
width: 800px;
padding-top: 5px;
padding-bottom: 5px;
background-color: #675c47;
}

Box-Shadow Won't work on my website

When trying to display image effects on my website they don't display.
If I run the image on jsfiddle.net it works perfectly fine. However my image doesn't work when i test it inside all my code. I want a border shadow effect all around the image. The code to do so is in my code but as you can see in my web site image there is no shadow.
Here is the image when I test it in jsfiddle.net without an image.
My code:
CSS:
#collage-container {
/*width: 699px;*/
width: 800px;
/*height: 510px;*/
height: 320px;
float: left;
margin-left: 200px;
margin-top: 10px;
background-color: #DADADA;
}
#collage-one{
width: 699px;
height: 300px;
margin-left: 50px;
margin-top: 10px;
box-shadow: 0 0 20px black;
}
HTML:
<div id = "collage-container">
<img src = "longblue.jpg" id = "collage-one"/>
</div>
Update: here is all my css
<head>
<style type = "text/css">
/* Formating for body of Web Site */
* {margin: 0; padding: 0;}
body {
font-family: times new roman;
background-color: #ebebeb;
}
/* Fixed screen size so objects don't shift */
#screen {
/*
min-width: 768px;
min-height: 100% !important;
margin-bottom: 30px;
*/
/* This locks everything in place*/
top:0px;
margin: 0 auto;
width:1500px;
height: 100%;
padding-top:0;
padding-bottom: 30px;
margin-bottom: 150px;
postion: absolute;
margin-left: 70px;
}
/* Format for black strip header */
#header {
background-color: black;
height: 168px;
width: 100%;
position: relative;
}
/* Class1: Holds the navigation buttons in header */
.container {
width: 960px;
height: auto;
margin: 0 auto;
margin-left: 0;
}
/* Class2: Holds the small containers for short articles */
.containerShort {
width: 480px;
height: auto;
margin: 0 auto;
}
/* Sub Classes: For Class2 */
.short1 {
right: 30px;
}
.short2 {
right: 30px;
}
/* Format for Tree logo in header */
#logoArea {
width: 300px;
height: 168px;
background-image: url(treesmall.jpg);
float: left;
margin-left: 30px;
}
/* Formating for location of navagation buttons */
#navArea
{
height: 100%;
float: right;
margin-right: 0px;
margin-top: 80px;
margin-left: 100px;
}
/* Removes the bullets for navagation buttons in header */
#nav
{
list-style: none;
}
/* Navagation formating */
#nav a
{
color: white;
text-decoration: none; /*removes underline*/
}
/* Formats the links of navagation buttons */
#nav li
{
float: left;
margin-left: 60px;
background-color: #252525;
padding: 8px;
bording: 1px solid silver;
border-radius: 5px;
}
/* Makes a hovering effect where when the mouse hovers over the
links they change color */
#nav li:hover
{
background-color: gray;
}
/* Sub class formating for container class */
.page
{
background-color: white;
padding: 10px;
margin-top: 10px;
width: 1100px;
float: right;
border-radius: 5px;
padding-bottom: 1px;
}
/* Side quote article main page */
.article
{
background-color: #ebebeb;
padding-top: 1px;
margin-top: 20px;
width: 120px;
float: right;
border-radius: 20px;
height: 300px;
border: 1px solid black;
margin-right: 20px;
text-align: left;
}
/* Formating for left sidebar of information */
#sidebar {
background-color: #B4B4B4;
height: auto;
width:350px;
float:left;
margin-top: 10px;
border-radius: 5px;
padding: 10px;
color: #483D8B;
}
/* footer formating */
#footer {
background-color: black;
height: 40px;
width: 1500px;
color: white;
padding-top: 10px;
position: relative center;
bottom: 0;
text-align: center;
margin-left:70px;
}
/* Formating of Header quote */
#quote {
color: white;
float: right;
}
/* Paragraph formating */
p {
color: black;
margin-bottom: 20px;
padding: 5px;
padding-left: 40px;
}
p.light {
color: white !important;
margin-bottom: 60px;
padding: 5px;
padding-left: 40px;
}
p .imagespace {
padding-left: 40px;
margin: auto;
}
h3 {
margin-bottom: 60px;
}
h2 {
font-family: "Times New Roman";
font-style: oblique;
}
#collage-container {
/*width: 699px;*/
width: 800px;
/*height: 510px;*/
height: 320px;
float: left;
margin-left: 200px;
margin-top: 10px;
background-color: #DADADA;
}
#collage-one{
width: 699px;
height: 300px;
margin-left: 50px;
margin-top: 10px;
box-shadow: 0 0 20px black;
}
/*#collage-two,#collage-three,
#collage-four{
width: 226px;
height: 200px;
padding: 5px;
background-color: black;
background-position: top center;
float: right;
}*/
/*#space {
width:300px;
height: 508px;
background-color: white;
float: left;
margin-top: 0;
margin-left: 120px;
box-shadow: hshadow, vshadow blur color
box-shadow: 10px 0 20px #B4B4B4;
border-radius: 10px;
}*/
#ego {
box-shadow: 0 0 20px #B4B4B4;
}
#marquee{
color: #483D8B;
margin-top: 10px;
margin-bottom: 0px;
width: 1025px;
float: right;
}
</style>
</head>
From advice in comments, looks like I have to fix my shadow to accept more browser versions.
Thanks everyone I will play with it.
Main help: #Phillips126

HTML position sidebar next to content

i am currently trying to move my sidebar from below the content box to the right of it alongside it. No matter what i try it stays at a certain point no going up any higher. My website is VAGUE LINES, where if you scroll down a bit u will be able to see exactly what i am saying.
Below is my css code thanks alot:
h1
{
text-align:center;
font-family:sans-serif;
letter-spacing:12px;
padding-bottom:6px;
border-top:1px solid rgb;
margin-top:35px;
color:#544E4F;
font-weight:lighter;
}
hr
{
display:overline-block;
width:200px;
}
#header
{
background: #FFFFFF;
text-align: center;
}
#navigation ul
{
margin: 0;
padding: 0;
list-style-type: none;
text-align: center;
}
#navigation ul li
{
display: inline;
padding-right: 30px;
}
#navigation ul li a
{
text-decoration: none;
padding: .3em 5em;
color: #000000;
background-color: #FFFFFF;
font-family: courier;
}
#navigation ul li a:hover
{
text-decoration: line-through;
}
.centeredImage
{
float: none;
margin: 4% 0 2% 9%;
text-align: center;
padding-bottom: 25px;
}
#main-content hr
{
width :66%;
margin-left: 9%;
}
#main-content
{
width:80%;
padding-left: 113px;
padding-top: 20px;
}
#page-wrap {
background: white;
min-width: 780px;
max-width: 1260px;
margin: 10px auto;
}
#page-wrap #inside {
margin: 10px 10px 0px 10px;
padding-top: 10px;
padding-bottom: 10px;
}
#sidebar{
border-top: 1px solid #99CC33;
border-left: 1px solid #99CC33;
height: 300px;
width: 200px;
margin-right: 5px;
padding: 5px 0 0 5px;
position:absolute;
}
#main-content p
{
margin-left: 10%;
font-family: courier;
font-size: 14px;
}
#heading p
{
margin-left: 10%;
font-family: sans-serif;
font-size: 14px;
}
#sidebar p
{
margin-left: 10%;
font-family: courier;
font-size: 14px;
font-weight:bold;
}
Try this:
#main-content
{
float: left; // float element to the left side
width:80%;
padding-left: 113px;
padding-top: 20px;
}
#sidebar{
border-top: 1px solid #99CC33;
border-left: 1px solid #99CC33;
height: 300px;
width: 200px;
margin-right: 5px;
padding: 5px 0 0 5px;
position:absolute;
right: 0; // position element to the right
}
EDIT: Sorry. You wanted sidebar on the right.