CSS border styling fitting content - html

I've been having trouble fitting some content into a border. When entering more text, instead of extending to fit vertically it just continues past the border as shown in the attached screenshot:
And my CSS file is as follows:
body {
background-image:url(http://www.cs.aub.edu.lb/hsafa/cmps278/hw2/background.png);
background-repeat:repeat;
background-attachment:fixed;
margin: 0px;
padding: 0px;
font-family: Verdana, Tahoma, sans-serif;
}
h1 {
text-align: center;
font-family: Tahoma, Verdana, sans-serif;
font-size: 24pt;
text-shadow: 3px 3px #999999;
font-weight: bold;
}
p {
font-size: 8pt;
}
#content {
width: 800px;
margin: auto;
border: 4px solid gray;
border-radius: 20px;
background-color: #A2B964;
}
#banner {
height: 50px;
background-image:url(http://www.cs.aub.edu.lb/hsafa/cmps278/hw2/bannerbg.png);
background-repeat:repeat;
}
#banner img {
display: block;
margin:auto;
overflow: hidden;
}
#general {
float: right;
width: 250px;
border-radius: 0px 20px 0px 0px;
}
dl {
margin: 10pt;
font-size: 8pt;
font-family: Ariel, sans-serif;
}
dt {
font-weight: bold;
margin-top: 10pt;
}
ul {
list-style-type: none;
}
li {
margin-left:0px;
}
#leftsection {
width: 550px;
overflow:hidden;
background-image:url(http://www.cs.aub.edu.lb/hsafa/cmps278/hw2/background.png);
background-repeat:repeat;
background-attachment:fixed;
}
#rating {
height: 83px;
background-image:url(http://www.cs.aub.edu.lb/hsafa/cmps278/hw2/rbg.png);
background-repeat: repeat;
overflow: hidden;
border-radius: 20px 0px 0px 0px;
}
#rating img {
border-radius: 20px;
}
.special {
vertical-align: top;
font-size: 48pt;
font-weight: bold;
color: red;
}
.review {
font-size: 8pt;
font-family: Verdana, Tahoma, sans-serif;
font-weight: bold;
background-color: #E8DC9B;
border: 2px solid gray;
border-radius: 10px;
padding-left: 8px;
padding-right: 8px;
}
.personal {
margin-bottom: 20pt;
}
.italic {
font-style: italic;
margin-left: 40px;
}
img.review {
padding-right: 5px;
}
#leftcol {
margin-top: 2%;
margin-left: 2%;
margin-right: 2%;
float: left;
width: 47%;
}
#rightcol {
margin-top: 2%;
margin-right: 2%;
float: right;
width: 47%;
}
#pages {
text-align:center;
margin: 5px;
}
#validated {
position: fixed;
top: 90%;
left:80%;
width: 600px;
}
#validated img {
opacity: 0.5;
}
I've added the HTML code on CSSDeck: http://cssdeck.com/labs/full/bldwwaec

It would be better if you put the HTML codes too.
The right side element is either fixed (or absolute) or float. If it is float, you can simple fix it with adding a <br /> at the end of its parent element and set clear: both; on it. Like this:
<div id="parent">
<div>aaa</div>
<div class="float-right">bbbb</div>
<br style="clear: both;" />
</div>
Now, the div#parent fits with the content and if you set a border on it, your problem would fix.
In absolute case, however, it is not as easy as I explained and recommend revising the use of absolute (or fixed) for that part.
Good luck,
Mohammad Ali Sharpasand

Of course today, float is no longer needed, as the flexbox is available:
https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox
Also, grid is amazing:
https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Grids

you have to put one more div over the id=content and you can call the calss=pagewrapper.
.pagewrapper{
margin: 0 auto;
width: 800px;
}
put float:left in your ID
#content{
float: left;
}

The problem appears to be the floating right column.
#rightcol {
float: right;
}
It would appear you need to clear the float, since floating elements are removed from normal page flow, the parent element will not expand to match the height. A simple solution is to add a clearfix to your parent element or class (in our case ID)
#content:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
This should solve your issue, if you have more questions about this I would suggest looking here.

Related

html with embedded css file not filling up Body

I am trying to create the following resume using html/css, and the actual resume is not filling up the body of the html.
resume 1
resume2
The CSS code for the resume is as follows.
<style>
body {
background-color: white;
width: 612px;
height: 792px;
}
h1 {
margin-top: 15px;
margin-bottom: 0px;
text-align: center;
color: black;
font-size: 70px;
}
html, body {
overflow: auto;
}
h1:after {
content:' ';
display:block;
border:3px solid black;
margin-bottom: 0px;
}
p{
font-weight: bold;
font-size: 30px;
color: black;
margin-bottom: 15px;
margin-top: 15px;
}
dt {
display: list-item;
list-style-type: disc;
list-style-position: inside;
}
dl {
margin-top: 15px;
}
h3 {
text-align: left;
font-size: 19px;
color: black;
margin-bottom: 4px;
}
</style>
I was wondering if there is any CSS line that can fix this issue
This is probably the reason:
body {
width: 612px;
height: 792px;
}
You're forcing the whole body of your website to be set at 612x792 pixels, so of course it won't fill up the entire view

How to centering span

How to centering that download button? I tested many times but it's wrong codes.
.col {
width: 100%;
height: auto;
float: left;
}
.download {
width: auto;
font-weight: 600;
font-size: 14px;
color: #000;
border: 2px solid #000;
padding: 17px 37px;
margin-top: 30px;
float: left;
}
<div class="col">
<span class="download">Download</span>
</div>
Just add text-align: center; to .col and replace float:left with display:inline-block; in the button element. jsfiddle
Remove float:left; from .download (because it forces the element to be floated to the left).
Give display:inline-block; (It acts like inline element, it means you can center it by giving text-align:center; to its parent.)
JSFiddle
.col {
width: 100%;
height: auto;
float: left;
text-align: center;
}
.download {
font-weight: 600;
font-size: 14px;
color: #000;
border: 2px solid #000;
padding: 17px 37px;
margin-top: 30px;
display: inline-block;
}

Problems with moving element CSS

I'd like to move element h1 a bit down but without moving the whole div block.
HTML code is here:
<div class="mainblock"></div>
<div class="under"><h1>Some text</h1></div>
CSS rules is here:
.mainblock {
margin: 40px auto 0 auto;
width: 40%;
height: 250px;
background-color: cadetblue;
}
.under {
margin: 0 auto;
width: 40%;
height: 250px;
background-color: coral;
}
h1 {
text-align: center;
font: 40px/30px Tahoma,sans-serif;
font-weight: 900;
color: azure;
/* Here I add some margin for H1 */
margin-top: 20px;
}
How can I move h1 tag only?
Using padding is not suitable because it adds some space and if it were a link it created some clickable space which I don't need.
Use position:relativeon the h1 element to move it without it affecting the position of any other elements.
h1 {
position:relative;
top:20px;
text-align: center;
font: 40px/30px Tahoma,sans-serif;
font-weight: 900;
color: azure;
/* Here I add some margin for H1 */
margin-top: 20px;
}
You can move it by adding line-height
Another possibility to achieve what you want is using positioning like so:
.under {
margin: 0 auto;
width: 40%;
height: 250px;
background-color: coral;
position:relative;
}
h1 {
text-align: center;
font: 40px/30px Tahoma,sans-serif;
font-weight: 900;
color: azure;
position:absolute;
top: 20px;
}
It looks like padding-top does what you want if the link is inside the h1 tag.
HTML
<div class="mainblock"></div>
<div class="under"><h1>Some text</h1></div>
CSS
.mainblock {
margin: 40px auto 0 auto;
width: 40%;
height: 250px;
background-color: cadetblue;
}
.under {
margin: 0 auto;
width: 40%;
height: 250px;
background-color: coral;
}
h1 {
text-align: center;
font: 40px/30px Tahoma,sans-serif;
font-weight: 900;
color: azure;
/* replace margin-top with padding-top */
padding-top: 20px;
}
Here's a fiddle...I changed the padding from 20px to 60px to make it easier to see that there's no clickable space above the text.
http://jsfiddle.net/htpb9bdk/
Provide the position:absolute to parent and child element
try this : http://jsfiddle.net/heuek2za/
.mainblock {
margin: 40px auto 0 auto;
width: 40%;
height: 250px;
background-color: cadetblue;
margin-left:28%;
}
.under {
margin: 0 auto;
position:absolute;
width: 40%;
height: 250px;
background-color: coral;
margin-left:27%;
margin-top:4%;
}
h1 {
text-align: center;
position:absolute;
font: 40px/30px Tahoma,sans-serif;
font-weight: 900;
color: azure;
/* Here I add some margin for H1 */
margin-top: 50%;
}
You can also apply float:left;width 100% to H1 which makes your margin to work.
The new CSS for h1 becomes:
h1 {
color: azure;
float: left;
font: 900 40px/30px Tahoma,sans-serif;
margin-top: 20px;
position: relative;
text-align: center;
width: 100%;
}

Image is displayed unusually big when inside a page

I have this image:
http://www.problemio.com/img/phoneimage.png
But when I placed in inside a page like this:
<div style="float:left">
<img src="https://i.stack.imgur.com/83Z5U.png" style="border: none;" />
</div>
<div style="float:left">
<p>
Some text
</p>
<p>
Some text
</p>
</div>
It got displayed as very big. Here is how it looks on a test page:
http://problemio.com/business/business_economics.php
Would anyone know why that happened? It is really unexpected. Here is the css I am working with
/* layout styles across the problemio project */
html
{
background-color: #ECE5B6;
#4a4647;
}
body, html
{
padding: 5px;
}
body
{
font-family: "Century Gothic",Helvetica,Arial,sans-serif;
margin: 0;
padding: 0;
font-size: 1.3em;
#background-color: #5C5957;
#background-color: #4a4647;
#background:url(/img/ui/background_image.png) top left no-repeat;
#background-size: 100%;
}
/* makes the background of the top bar gray */
.container
{
position: relative;
background-color: white;
overflow:hidden;
width:1000px;
margin: 0 auto;
-moz-border-radius: 15px;
border-radius: 15px;
}
.container_home
{
position: relative;
background-color: white;
overflow:hidden;
width:1000px;
margin: 0 auto;
}
div#bd
{
/* background-color: #f5f6f6; */ /* some form of gray */
background-color: white;
border-style:solid;
border-width:1px;
}
/* styles for banner: */
.banner
{
position: relative;
height: 40px;
background-size:100%;
#background-color: #4a4647;
}
.site_title
{
float:left;
margin-top: -3px;
margin-left: 10px;
font-weight: bold;
color: #ffce2e;
text-shadow: 2px 2px 2px rgba(0,0,0,0.8);
font-size:2.5em;
text-align: left
text-color: black;
width: 300px;
}
.site_login
{
width: 700px;
float:right;
position: absolute;
right: 10px;
bottom: 10px;
font-size: 90.0%;
color: gray;
text-align: right;
text-align: bottom;
}
/*
.bgdiv
{
position:absolute;
right:0px;
left:240px;
top:0px;
bottom:0px;
background-image: url('http://www.problemio.com/img/ui/banner_background.png');
#background-repeat: no-repeat;
}
*/
/* styles for basic template */
.content .basic
{
background: #fff;
padding: 15px;
border: 1px solid #888;
border-color: gray;
text-align: left;
}
.content .basic h1{
font-size: 2em;
font-weight:bold;
text-align: center;
}
.content .basic h2{
font-size: 1.5em;
font-weight:bold;
}
.content .basic h3{
font-size: 1.0em;
font-weight: bold;
}
#layout
{
/*margin:auto; */
#margin-top: 5px;
padding-right: 20px;
padding-left: 20px;
text-align:left;
/* background-color: #EDEDED; */
}
label span
{
float: left;
width: 15em;
}
p.half_text
{
font-size: 80.0%;
font-type: arial;
}
span.half_text
{
font-size: 80.0%;
font-type: arial;
}
p.half_height
{
margin: 5px 0;
}
.index_problem_title:visited
{
font-weight:bold;
text-decoration: none;
}
.index_problem_title
{
font-weight:bold;
text-decoration: none;
}
.index_problem_title:hover
{
text-decoration:underline;
color: gray;
}
footer a
{
color: white;
}
div.footer
{
text-align: right;
#color:#999999;
color: white;
background-color: black;
font-family:arial,times,serif;
font-size:18px;
#padding-top:20px;
line-height:150%;
position:relative;
float:right;
bottom:10px;
#height: 100px;
style: clear:both;
width: 1000px;
#background:url(/img/ui/footerbar.png) top left no-repeat;
}
#tabs-1
{
padding-left: 10px; !important;
}
.ui-tabs-panel
{
padding: 5px !important;
}
.ui-widget-header
{
background-image: none;
background-color: #EBEBEB;
padding-left: 50px;
}
.ui-state-default
{
background-image: none;
background-color: Gray;
}
To make adjacent,
<div style="float: left; width: 68%; display: inline;">
<img width="60%" height="60%" style="border: none;" src="http://www.problemio.com/img/phoneimage.png">
</div>
<div style="display: inline; float: left; width: 28%;">
<p>
Understanding and correctly forecasting the unit economics of your business is extremely important. It is a large part of a successful business plan, and the business itself. The term might sound complicated, but it is surprisingly simple. At least we will try to make it so with an example.
</p>
<p>
In an effort to make this material easy and fun to understand, we will actually go over the unit economics of a real business. Our example business: A single-location exercise gym. We will call it Bob's Fitness.
</p>
</div>
Actually , I just added some inline css to your code,you can made them in class or id also
#layout div img
{
max-width: 100%;
width: 100%;
}
Add this css in your page or place as you want.
I see you are modifying it :-) i'm testing with firebug!
In any case I tested it there
http://jsfiddle.net/eb56N/2/
I've just added
<img style="border: none; width: 100%;" src="http://www.problemio.com/img/phoneimage.png">
Maybe you already changed something.

CSS no background image, any ideas?

I'm trying to get my background image to show at the top center of the page. The image works fine if I do:
<style>
body {
background: #FFF url('img/top_logo_blank_small.png') no-repeat fixed;
}
</style>
I can't seem to work out where I've gone wrong. There must be something I've managed to mess up, I just can't see it. Here is the CSS:
body {
font-family: 'Quattrocento Sans', helvetica, sans-serif;
background: #EEE url('img/top_logo_blank_small.png') no-repeat fixed;
color: #fff;
margin: 0;
padding: 0;
}
a {
color: black;
text-decoration: none;
}
/* Typography */
.header h1 {
position: absolute;
width:100%;
top: 50%;
margin-top: -20px;
text-align: center;
letter-spacing: 4px;
}
.header h1 em {
font-size: 1.200em;
font-style: normal;
}
h1 {
font-size: 2.2em;
color: #fff;
}
.content h2 {
font-size: 1.75em;
color: #fff;
letter-spacing: 4px;
text-align: center;
}
.content h2 em {
font-size: 1.2em;
font-style: normal;
}
.content h3 {
text-align: center;
font-size: 1.0em;
font-weight: normal;
color: #ede0ed;
letter-spacing: 1px;
margin-bottom: 25px;
}
.content h4 {
margin-top: 0;
text-align: center;
font-size: 0.8em;
font-weight: normal;
color: #ede0ed;
letter-spacing: 1px;
}
#banner p {
text-align: center;
}
/* Navigation */
#nav {
margin: 4px 4px 40px;
}
#nav ul {
padding: 0;
margin: auto;
list-style: none;
}
#nav ul li {
width: 50%;
color: #BBB;
float: left;
font-family: 'Cabin Sketch';
font-size: 1.75em;
text-align: center;
background: url(img/scribble_dark.png);
}
#nav ul li a {
display: block;
/*padding: 5px 20px;*/
}
#nav ul li a:hover {
background: #e0d0e0;
}
/* Content */
.container{
max-width: 720px;
margin: 50px auto 0;
background: #FFF url('img/top_logo_blank_small.png') no-repeat fixed 0 0;
}
.header {
position: relative;
background-color: #b88fb8;
border-top: 5px solid #ede0ed;
height: 75px;
}
.content {
background-color: #000;
padding: 15px;
margin-bottom: 10px;
}
div#about {
padding:25px;
min-height: 255px;
}
img#portrait {
float: left;
margin-right: 25px;
width: 256px;
height: 256px;
}
div#footer {
width: 100%;
max-width: 720px;
margin: auto;
color: black;
text-align: right;
padding: 0 10px;
font-size: 0.850em;
}
#media screen and (max-width: 650px) {
.container {
width: 90%;
max-width: none;
}
div#footer {
width: 90%;
}
}
Try to change your path for example:
background: #EEE url('../img/top_logo_blank_small.png') no-repeat fixed top;
Because you are in a subfolder, you have to go up of a level I think
Most likely your css file is in a different folder and therefore needs another path to the image file.
The common way is to put css in a separate css/* folder, so the path should be:
url('../img/top_logo_blank_small.png')
This CSS seems to work fine, are you certain that the image exists?
http://jsfiddle.net/ghsNR/
I've just tried it here and it works fine with an image from http://placehold.it/
body {
font-family: 'Quattrocento Sans', helvetica, sans-serif;
background: #EEE url('http://placehold.it/500x500') no-repeat fixed top;
color: white;
margin: 0px;
padding: 0px;
}
The most likely cause after observing this is that your CSS isn't actually locating your image correctly. I suggest using tools like the Chrome dev tools, or Firebug to inspect the absolute path that the browser is trying to use to load the image and moving forward from there.
Is the css in the same folder as the page? If you have a different folders, you need to change the URL accordingly.
Maybe change the URL to
'../img/top_logo_blank_small.png'