Strange issue with a border going to the above div? - html

I want my bordered div to look like:
neat and just wrapped around the div right under the two img divs. (Adding a hyphen or period separates the div to separate and lets it go below).
but instead, I'm getting
where it looks like it's going up and hooking to the above divs — ideas?
This is my css:
tallcrop {
width: 49%;
height: 55vh;
overflow: hidden;
float: left;
align: left;
display: inline-block;}
tallcrop img{
position:center;
height: 100%;
object-fit: cover;}
.leftside {
margin-top: .5%;
padding-right: 1%;
padding-bottom: 1.5%;
padding-top: 0%;}
.rightside {
margin-top: .5%;
padding-left: 1%;
padding-bottom: 1.5%;
padding-top: 0%;}
fluid box {
width: 100%;}
fluidbox p {
border: .06em solid black;
height: ;
font-face:'ag';
line-height: 1em;
font-size: 3em;
padding: 1%;
}
and HTML:
<!--Fires-->
<tallcrop class="leftside">
<img src="https://static1.squarespace.com/static/598ca765c534a5280a3fb1ef/t/59c043674c0dbf745deee657/1505772425232/DSC_0909.jpg"></tallcrop>
<!--Small Editions-->
<tallcrop class="rightside"><img src="https://static1.squarespace.com/static/598ca765c534a5280a3fb1ef/t/59c04447be42d644772fc2bf/1505772633670/Small_Editions1.jpg"></tallcrop>
<!--Fluid-->
<fluidbox>
<p>On the Democratic <font face="ab">Fluidity</font> of Digital Artist Books</p></fluidbox>

You are using float for the left and right alignment. If you are using this property you must need to use clear: both CSS property.
Elements after a floating element will flow around it. To avoid this, use the clear property or the clearfix hack as given below.
I have added this HTML tag below the tallcrop tag:
<div class="clearfix"></div>
Here is the CSS:
.clearfix {
clear: both;
}
Here is the demo:
tallcrop {
width: 49%;
height: 55vh;
overflow: hidden;
float: left;
align: left;
display: inline-block;}
tallcrop img{
position:center;
height: 100%;
object-fit: cover;}
.leftside {
margin-top: .5%;
padding-right: 1%;
padding-bottom: 1.5%;
padding-top: 0%;}
.rightside {
margin-top: .5%;
padding-left: 1%;
padding-bottom: 1.5%;
padding-top: 0%;}
fluid box {
width: 100%;}
fluidbox p {
border: .06em solid black;
font-face:'ag';
line-height: 1em;
font-size: 3em;
padding: 1%;
}
.clearfix {
clear: both;
}
<!--Fires-->
<tallcrop class="leftside">
<img src="https://static1.squarespace.com/static/598ca765c534a5280a3fb1ef/t/59c043674c0dbf745deee657/1505772425232/DSC_0909.jpg"></tallcrop>
<!--Small Editions-->
<tallcrop class="rightside"><img src="https://static1.squarespace.com/static/598ca765c534a5280a3fb1ef/t/59c04447be42d644772fc2bf/1505772633670/Small_Editions1.jpg"></tallcrop>
<!--Fluid-->
<div class="clearfix"></div>
<fluidbox>
<p>On the Democratic <font face="ab">Fluidity</font> of Digital Artist Books</p></fluidbox>
You can also edit it on Codepen.

It is because you haven't cleared your floats and also as you are using custom html elements, it doesn't know what type of element it is (ie inline, block, etc). You can fix your code with the following:
fluidbox { /* remove the space between fluid and box in your css */
width: 100%;
display:block; /* make it a block element */
clear:left; /* clear your left float */
}
Your fixed code:
tallcrop {
width: 49%;
height: 55vh;
overflow: hidden;
float: left;
display: inline-block;
}
tallcrop img {
position: center;
height: 100%;
object-fit: cover;
}
.leftside {
margin-top: .5%;
padding-right: 1%;
padding-bottom: 1.5%;
padding-top: 0%;
}
.rightside {
margin-top: .5%;
padding-left: 1%;
padding-bottom: 1.5%;
padding-top: 0%;
}
fluidbox {
width: 100%;
display:block;
clear:left;
}
fluidbox p {
border: .06em solid black;
line-height: 1em;
font-size: 3em;
padding: 1%;
}
.clearfix {
clear: both;
}
<!--Fires-->
<tallcrop class="leftside">
<img src="https://static1.squarespace.com/static/598ca765c534a5280a3fb1ef/t/59c043674c0dbf745deee657/1505772425232/DSC_0909.jpg"></tallcrop>
<!--Small Editions-->
<tallcrop class="rightside"><img src="https://static1.squarespace.com/static/598ca765c534a5280a3fb1ef/t/59c04447be42d644772fc2bf/1505772633670/Small_Editions1.jpg"></tallcrop>
<!--Fluid-->
<fluidbox>
<p>On the Democratic
<font face="ab">Fluidity</font> of Digital Artist Books</p>
</fluidbox>

Related

How do I make my float: right images align with my other images?

I'm trying to make a grid-like photo gallery. The format I'm going for is 2 smaller photos on either side of one central picture. However when I try to float my right images they appear way too far down and nothing I've tried will move them up. Any help would be appreciated
The HTML:
<div id="body">
<div id="showsback">
<img class="showpicleft" src="images/zek.jpg">
<img class="showpicleft" src="images/kaes.jpg">
<img class="showpiccenter" src="images/cob.jpg">
<img class="showpicright" src="images/neil.jpg">
<img class="showpicright" src="images/gav.jpg">
</div>
</div>
The CSS:
#showsback {
background-image: url(images/SDSOback.jpeg);
background-size: 25%;
background-repeat: repeat;
margin-left: auto;
margin-right: auto;
border: 1em #f2f1ba solid;
text-align: center;
height: 100%;
}
.showpiccenter {
margin-top: .5em;
max-width: 30%;
display: block;
padding-bottom: .5em;
clear: both;
}
.showpicleft {
max-width: 30%;
margin-top: 1.25em;
margin-right: .5em;
margin-left: .5em;
float: left;
display: block;
clear: both;
}
.showpicright {
margin-top: 1.25em;
max-width: 30%;
display: block;
float: right;
clear: both;
}

White Space Following float: left and clear: both

I am using float: left to stack two divs side by side. I am then using clear: block to clear the float, but a small white space appears between the floated divs and the next div.
I have added overflow: none to every element on the page because I saw that as the solution that worked for other people with a similar issue, but that didn't fix the issue.
#featured-container {
position: relative;
width: 100%;
text-align: center;
margin-top: -60px;
}
#featured-header {
display: inline-block;
width: 240px;
height: 30px;
}
#featured-label {
float: left;
width: 160px;
height: 30px;
line-height: 30px;
text-align: center;
background: #EEEEEE;
font-weight: 700;
}
#featured-point {
float: left;
width: 0;
height: 0;
border-bottom: 30px solid #EEEEEE;
border-right: 30px solid transparent;
}
#featured {
display: inline-block;
width: 220px;
min-height: 220px;
padding: 10px;
background: #EEEEEE;
}
.clear {
clear: left;
}
<div id="featured-container">
<div id="featured-header">
<div id="featured-label">FEATURED</div>
<div id="featured-point"></div>
</div>
<div class="clear"></div>
<div id="featured">
</div>
</div>
EDIT: I know I can add a negative margin-top to the '#featured' box, but I would really like to understand why this problem exists.
Try changing the inline-block to inline-flex
#featured-header {
display: inline-flex;
width: 240px;
height: 30px;
}
Set font-size: 0; on the parent element. The space is a character space, so setting the font-size to zero makes the size of the space zero as well. But, you'll need to set the font size of the inline-block child elements back to your desired size.
#featured-container {
position: relative;
width: 100%;
text-align: center;
margin-top: 0px;
font-size:0px;
}
#featured-header {
display: inline-block;
width: 240px;
height: 30px;
}
#featured-label {
float: left;
width: 160px;
height: 30px;
line-height: 30px;
text-align: center;
background: #EEEEEE;
font-weight: 700;
font-size:18px;
}
#featured-point {
float: left;
width: 0;
height: 0;
border-bottom: 30px solid #EEEEEE;
border-right: 30px solid transparent;
}
#featured {
display: inline-block;
width: 220px;
min-height: 220px;
padding: 10px;
background: #EEEEEE;
font-size:16px;
}
.clear {
clear: left;
}
<div id="featured-container">
<div id="featured-header">
<div id="featured-label">FEATURED</div>
<div id="featured-point"></div>
</div>
<div class="clear"></div>
<div id="featured">
</div>
</div>

3 DIVs, 1 Container, Centrally aligned horizontally

I've got three DIVs that I've put into a container DIV.
What I want is as follows:
Here's where I'm up to:
#light-table {
background-color: #e2e2e2;
width: 100%;
padding-top: 15px;
padding-bottom: 15px;
padding-left: 40px;
padding-right: 40px;
text-align: left;
margin-top: 30px;
margin-bottom: 30px;
}
#leftdiv {
float: left;
padding: 0 20px;
/*margin:20px 0;*/
position: relative;
width: 25%;
flex-basis: 25%;
}
#leftdivcontainer {
vertical-align: middle;
width: 100%;
text-align: center;
}
#light-table-paragraph {
font-family: 'Droid Serif';
font-size: 20px;
color: #2e2e2e;
text-align: left;
line-height: 40px;
}
<div id="light-table">
<h3 id="light-table-head-style">content.</h3>
<div id="leftdivcontainer">
<div id="leftdiv">
<p id="light-table-paragraph">Left</p>
</div>
<div id="leftdiv">
<p id="light-table-paragraph">Middle</p>
</div>
<div id="leftdiv">
<p id="light-table-paragraph">Right</p>
</div>
</div>
</div>
Please can someone help tell me where I'm going wrong?
Thanks!
Scott
set the div the contains the three small divs display:flex and give it 75% width of the container, then set space around the content as follow:
#leftdiv {
/*float: left;*/
padding:0 20px;
/*margin:20px 0;*/
position:relative;
/* edits */
width:33.33%;
flex-basis: 25%;
}
#leftdivcontainer {
vertical-align:middle;
text-align: center;
/* edits */
width:75%;
display: flex;
margin: 0px auto;
justify-content: space-around;
}
#light-table-paragraph {
font-family: 'Droid Serif';
font-size: 20px;
color: #2e2e2e;
text-align: left;
line-height:40px;
}
#light-table {
background-color: #e2e2e2;
width: 100%;
padding-top: 15px;
padding-bottom: 15px;
padding-left: 40px;
padding-right: 40px;
text-align: left;
margin-top:30px;
margin-bottom: 30px;
}
<div id="light-table">
<h3 id="light-table-head-style">content.</h3>
<div id="leftdivcontainer">
<div id="leftdiv"><p id="light-table-paragraph">Left</p></div>
<div id="leftdiv"><p id="light-table-paragraph">Middle</p></div>
<div id="leftdiv"><p id="light-table-paragraph">Right</p></div>
</div>
</div>
Here's how I would do it.
Give each .leftdiv (indeed this should be a class, id's are unique) 33% of total viewport width:
.leftdiv {
float: left;
width: 33%;
}
and center each paragraph inside these divs, give it 75% width:
.leftdiv p {
display: block;
width: 75%;
margin: 0 auto !important; /* you won't need !important if your code is well structured */
}
This is a cleaner solution, as you'll notice there is no horizontal scroll present.
Here is a codepen.
Also, you need to clear your parent div #leftdivcontainer (did that as well).
Hope this helps.

How to move image with css/html

I am trying to move an image. I Want it to be alligned with the title "Experience". Here is my code
html code
<header>
<h1>Experience</h1>
<div class="logo">
<img src="./img/exp.png">
</div>
</header>
and the css code
.logo{
width: 100px;
}
.logo img{
float: left;
margin-left: 0px 0px 0px 30px;
width: 150px;
height: 38px;
}
Just tweak the CSS a little:
.logo{
width: 100px;
display: inline-flex;
}
.logo img{
margin: auto 5px;
float: left;
width: 150px;
height: 38px;
}
Does this work?
This solution worked for me, but I have no idea for you as you didn't put your full code...
Try adding float:left to .logo and setting display: inline-block on your h1, like so:
*{
margin: 0px;
padding: 0px;
font-family: Arial, Helvetica, Sans-serif;
font-size: 34px
}
header{
background-image: url(../img/bar.png);
background-color: #00B9ED;
height: 75px;
border-bottom: 0px;
padding-left: auto;
padding-right: auto;
width: 100%;
}
.logo{
width: 100px;
float: left;
//display: inline-flex;
}
.logo img{
margin: auto 5px;
float: left;
width: 150px;
height: 38px;
}
h1 {
display: inline-block;
}
How about making margin-left: 0%; and margin-right. Depends where you want to move it.
You used shorthand for margin-left. We use shorthand for margin only. You did margin-left: top right bottom left instead. I don't think the program reads that correctly.

CSS, html two columns auto length

How do I make those columns to be same width? Not the fix way. I want to do it automatically. It means when one will contain more text it will be longer so the second one will be equally long.
CSS
article.leftnews {
float: left;
border-radius: 30px;
width: 43%;
padding-top: 1em;
padding-left: 1em;
padding-right: 1em;
overflow: auto;
border:5px solid #0000CC;
}
article.rightnews {
border-radius: 30px;
margin-left: 52%;
padding-top: 1em;
padding-left: 1em;
padding-right: 1em;
overflow: auto;
border:5px solid #000066;
}
section{
position:relative;
margin-left:auto;
margin-right:auto;
width: 700px;
text-align: justify;
}
My demo here
The best way to me is using CSS table and table-cell
http://jsfiddle.net/2d9917o7/
Update: for rounded corners style, additional <div> inside each table cell is needed.
http://jsfiddle.net/2d9917o7/1/
HTML
<div class="container">
<article class="leftnews">left<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>end</article>
<article class="rightnews">right</article>
</div>
CSS
.container {
display: table;
width: 100%;
}
.leftnews,
.rightnews {
display: table-cell;
width: 50%;
background: pink;
}
.leftnews {
background: lime;
}