Why CSS is cropping the bottom of my image? - html

I have a logo and text on the page and my items are floated left but this causes the bottom of the logo to cut off. No minus margins or paddings are used. Looking with XRAY and webdeveloper style finder I see that the img is getting cut short with no other elements around it, (it is just floated left). If I remove the float from the .logo the image appears whole, but larger and out of position
Here is the jsfiddle http://jsfiddle.net/9LGRx/ It seems to be a FF bug, works ok in Chrome and Safari.
html > body > header > div.wrapper > a.logo > img
HTML code
<header>
<div class="wrapper">
<a href="/" class="logo">
<img src="images/logo.png" alt="Showhouse logo">
</a>
<h1>Welcome to ShowHouse</h1>
<p class="text">
Show off your property management skills with ShowHouse - the only online property
management software that will effortlessly handle and help to improve every aspect of
your <strong>residential</strong> and <strong>commercial lettings</strong>, <strong>sales</strong> and <strong>block management</strong>.
</p>
</div>
</header>
SCSS Code
h1{
color: #fff;
float: left;
clear: both;
}
img{
max-width: 100%;
float: left;
}
header{
background-image: url('../images/header-bg.jpg');
float: left;
width: 100%;
/*height: 417px;*/
.logo{
float: left;
width: 60%;
margin: 20px 0 20px 0;
}
.logo img{
max-width: 100%;
}
.text{
float: left;
clear: both;
color: $color-white;
font-size: 1.2em;
margin-top: -10px;
}
}

Try adding this to your css:
.logo img{
max-width: 100%;
display: block;
height: 150px;
}
(put the real height of your image or the height you want to display)

Related

First element in Body tag is hard-stuck on top left corner

I've been having an issue with every single CSS exercise so far where the first element inside my body tag, whether it's an img or an h1 is simply stuck at the top left corner of the page (where the body tag starts, I assume) and it's just impossible to move it in any way, regardless of margin size or element width. I even tried adding a background color to it just to see if it would work and it didn't, so i guess that for some reasons, no modifications can be made to this element.
Here's my HTML
<body>
<header class="Top">
<img src="img/logo.png" alt="NeoDance Logo" width="356" height="48" class="logo">
<nav class="NavBar">
Home
About
Class schedules
Performances
Blog
Contact
</nav>
<div class="ClearFix"></div>
</header>
Here's my CSS. Note that before this displayed line, I'm using a completely unedited version of the Meyer css reset
header.Top{
width: 1440px;
margin: auto;
background-color: #303030;
overflow: hidden
}
div.wrapper
img.Logo{
margin-top: 35px;
margin-bottom: 35px;
margin-left: 250px;
margin: auto;
background-color: #303030;
}
nav.NavBar{
float: right;
width: 490px;
background-color: #303030;
list-style: none;
margin: auto;
margin-right: 250px
}
a.links{
float: right;
font-size: 15pt;
font-family: 'Muli', sans-serif;
color: #8c8c8c;
margin-top: 50px;
margin-right: 18px;
}
div.container 1{
width: 490px;
clear: both
}
img.dancers{
float: right;
}
div.ClearFix{
clear: both;
}
That img.logo should have margins applied, as specified in the css. However it's just stuck there, shown in the image below
Problem
I'm guessing you're talking about your logo, and not the actual header element.
For one, your css selector is wrong. It should be img.logo instead of img.Logo
Also, remove that div.wrapper code from your css. What's that doing there? Then remove the margin: auto from your img.logo style and you're good to go.
The order of declaration in CSS is important (hence the "Cascading").
Therefore, when you do :
img.Logo{
margin-top: 35px;
margin-bottom: 35px;
margin-left: 250px;
margin: auto;
background-color: #303030;
}
margin:auto overrides all of the margins above.
You should try to put margin:auto before the other margins and it should work.

Child divs wont fit to parent

I'm working on my portfolio site and having trouble getting my divs to size together.
Here it is: I have one body div, inside there are two child divs.
The body div should have max-height 100%, max-width: 100% so that it doesn't exceed the browser window.
The left div contains an image which I want to scale to the parent body div (max-height 100%, max-width 70%).
The right div contains text about the image, it needs to scale to the height of the left div (there is also footer that sits at the bottom of this div).
This shouldn't be so hard, its almost working but right now my image container (left div) is not being contained to the body div.
html,
body {
height: 100%;
}
.Info {
float: left;
width: 25%;
padding-left: 15px;
padding-top: 10px;
/*margin-left: 78%;*/
border-left: 1px black solid;
/*position: absolute;*/
}
.InfoText p {
margin-top: -10px;
}
div img {
max-width: 100%;
max-height: 100%;
margin: 0 auto;
box-shadow: 5px 5px 15px #888888;
}
.ImageContainer {
float: left;
height: 100%;
max-width: 70%;
padding-right: 15px;
position: relative
}
section.ImageContainer img {
float: left;
object-fit: cover;
}
#SideQuote {
margin-top: 30px;
}
.StuffInBody {
position: relative;
padding-top: 15px;
float: left;
display: flex;
}
footer p {
position: absolute;
bottom: 0%;
margin: 0;
}
<div class="StuffInBody">
<div class="ImageContainer">
<img class="contained" src="images/TheGMODebate copy.jpg" alt="" />
</div>
<div class="Info">
<div class="InfoText">
<p>ILLUSTRATION</p>
<p>Title: <em>The GMO Debate</em>
</p>
<p>Media: Gouache</p>
<div id="SideQuote">
<p class="ClickToEnlarge">Full screen image click here.
</p>
</div>
<footer>
<p>© Brooke Weiland 2015</p>
</footer>
</div>
</div>
</div>
It's very hard to make a reliable interface using floats.
It changes default behaviour and put your element outside of the flux.
You should be able to do what you want using only flex.
The property box-sizing: border-box also makes miracles (margin and padding easier to manage).
Also, the object-fit property is not enough supported by browsers to be used now IMHO.
http://caniuse.com/#feat=object-fit

css: impossible to grow the pricing page

check out this static tempalte from https://github.com/kybernetyk/medstime/tree/master/src/medstime/static
the page that I'm having trouble with is
https://github.com/kybernetyk/medstime/blob/master/src/medstime/static/plans-pricing.html
Inside the <aside> tag, when you try to increase the number of items, the <div class="grid">
stays fixed in height and size!
I've literally tried everything from setting height on it but it is impossible to grow the container as I add more content inside it.
I apologize in advance if you have already tried this. But I looked in the CSS code under saas-common.css and found this:
.grid aside {
width: 125px;
float: left;
padding-top: 110px;
text-align: right;
}
.grid aside li {
line-height: 51px;
font-size: 14px;
}
.grid .sections {
width: 782px;
height: 511px;
background: url(../images/bg-grid-box.png) no-repeat left top;
float: right;
}
.grid section {
float: left;
text-align: center;
height: 509px;
}
Looks like there are some fixed heights under the grid div. You could try overriding with !important.
A few things to try from there:
min-height: 500px;
height:auto;
Then,
overflow:hidden;
And if all else fails,
position:absolute;

webpage collapses when minimizing html & css

My body div collapses under the left bar navigation when i begin to minimize the window.
Can somebody please advise on what i have done wrong or what more i need to do.
Much appreciated, thank you.
css snippet:
#navigation {
float: left;
min-width: 20%;
margin: 0;
margin-top: 5px;
font-weight: normal;
}
#centerDoc {
float: left;
width: 80%;
padding: 0 0 20px 0; /*top right bottom left*/
margin-top: 0px;
}
#header{
position: relative;
width:100%;
height:96px;
margin-left: 5px;
}
#footer {
font-family: Trebuchet MS;
font-size: x-small;
padding:2px;
margin:0px;
background-color:#CBE3F6;
color:#fff;
border-bottom: 1px solid #9EC4E2;
border-top: 1px solid #9EC4E2;
text-align:center;
width: 100%;
}
#wrapper{
position: relative;
margin-left: 5px;
}
#container {
width: 100%;
height:100%;
}
Template of a page:
<?php require_once 'includes/header.php';?>
<div id="wrapper">
<?php require_once 'includes/nav.php'; ?>
<div id="centerDoc">
</div> <!--centerDoc !-->
</div> <!-- wrapper !-->
</div> <!--container !-->
</body>
Remove float attribute from #centerDoc, and add margin-left: 20%. to it
Then change min-width: 20% in #navigation to width: 20% or max-width: 20%. Without this the text inside centerDoc flows under the #navigation.
You might want to keep your measurement synchronized. You have width: 80% in #centerDoc and min-width in #navigation. It might be easier to picture the layout if you'd used plain width in both occasions and assigned the min/max-width attributes to the body of the page (so the widths of the #navigation and #centerDoc are relative to the common parent of them).
Edit: CSS:
#navigation {
float: left;
width:20%;
}
#centerDoc {
width: 80%;
margin-left:20%;
}
#header{
width:100%;
height:96px;
}
#container {
max-width: 1200px;
min-width: 600px;
}
Removed the #wrapper. See the max-/min-width´ in the#container. The scrollbars appear into the browser when the page is less then 600 pixels wide. The page also doesn't become wider then 1200 px. This allows you to define thewidths of the#navigationand#centerDoc` as percentages.
With the following HTML everything should work properly. (Althought I don't know what's inside nav.php. Hopefully nothing that clears the floating of the #navigation)
<div id="container">
<?php //require_once 'includes/header.php';?>
<div id="navigation">
<?php //require_once 'includes/nav.php'; ?>
<p>Sample text. Sample text. Sample text. Sample text. Sample text.</p>
</div> <!--navigation !-->
<div id="centerDoc">
<p>Sample text. Sample text. Sample text. Sample text. Sample text. Sample text.</p>
</div> <!--centerDoc !-->
</div> <!--container !-->
I would change min-width in #navigation to max-width.
That way we make sure that the left navigation bar has not more than the 20% of the width of the page.
Edit:
#navigation {
float: left;
width: 20%;
margin: 0;
margin-top: 5px;
font-weight: normal;
}
#centerDoc {
float: right;
width: 80%;
padding: 0 0 20px 0; /*top right bottom left*/
margin-top: 0px;
}

Floated parent only extended by content floated divs

I have some divs holidng images I want to display.
They are within a centered container.
This container has a variable width so depending on your browser size you have either 3 or 4 images in a row before they go flow into the next row. I want to have thoses images centered in the container elment. My problem now is, that this container element is always 100% so but the inside image divs do not fill it. I need the inner divs to expand the out div, so it is only as wide as all the 3 or 4 images and their margin.
My html is:
<div id='team'>
<div class='item-container'>
<div class='item'>
<img src='small.jpg' alt='' />
</div>
</div>
<div class='item-container'>
<div class='item'>
<img src='small.jpg' alt='' />
</div>
</div>
</div>
My css is:
#team{
margin: 20px 0px;
padding: 20px 0;
position: relative;
float: left;
}
#team .item-container{
position: relative;
float: left;
width: 230px;
height: 180px;
margin: 2%;
}
Anyone any ideas? If you do not get what I mean, please ask so I can describe it in more detail. Thanks in advance.
You can switch to using display: inline-block instead of float: left on the .items, and then text-align: center on #team to center:
See: http://jsfiddle.net/gGc76/8/ - (be sure to try resizing the window)
You possibly don't want float: left on #team, but I'm not sure what you're doing.
#team {
margin: 20px 0;
padding: 20px 0;
position: relative;
float: left;
background: #ccc;
text-align: center
}
#team .item-container {
vertical-align: top;
display: inline-block;
/* if you need ie7 support */
*display: inline;
zoom: 1;
position: relative;
width: 230px;
height: 180px;
margin: 2%;
background: #eee
}