I need to position some images, inline on the bottom of a container.
I tried to do as this question asks, but I can't understand why with me doesn't work and escapes from the container.
Could you help me? This is my code:
<div id="banner">
<div id="uscite">
<div id="jp"><img src="../img/uscite/scan.png" height="90" width="60" alt="" /><br />text</div>
<div id="it"><img src="../img/uscite/scan.png" height="90" width="60" alt="" /><br />text</div>
</div>
<div id="nav_main">
<div style="margin: 0 auto;"><img src="../inc/home.png" /></div>
<div style="margin: 0 auto;"><img src="../inc/staff.png" /></div>
<div style="margin: 0 auto;"><img src="../inc/forum.png" /></div>
<div style="margin: 0 auto;"><img src="../inc/disclaimer.png" /></div>
<div style="margin: 0 auto;"><img src="../inc/secret.png" /></div>
</div>
</div>
CSS:
div#banner{
padding:10px;
border:1px solid #444444;
background: url('header2.png') no-repeat center center;
height:400px;
}
div#nav_main{
position: absolute;
left: 0;
width: 1180px;
bottom: 0;
}
div#uscite{
padding:30px 20px;
float:right;
border:0px;
height:35%;
width:20%;
}
div#jp{
text-align: center;
width:50%;
height:100%;
float:left;
border:0px;
}
div#it{
text-align: center;
width:50%;
height:100%;
float:right;
border:0px;
}
http://jsfiddle.net/nu7eoj0q/1/
Edit: I'd also like add another div (called "social") under "uscite"'s one. but it doesn't appear. What am I wrong?
http://jsfiddle.net/faeba3v1/
I think you want to do this
Js Fiddle
new properties added
#nav_main div{
display:inline-block;
}
div#banner{
position:relative;
}
Related
I'm create html page called AboutUs.html. I was tasked to complete the page but there is a problem. I want to align the three box in horizontally something like this:
but I try using some CSS code but still could not align in horizontal.
Wrong Output:
I want the first box to be left, for second box to be center and the third box to be right. Can anyone please help me fix this problem.
This is About.html code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Two Trees Creative - About Us </title>
<link rel="stylesheet" href="_stylesheets/Css_Reset.css"/>
<link rel="stylesheet" href="_stylesheets/mystyle.css"/>
</head>
<body>
<div id="wrapper">
<header>
<a id="logo" href="#">Two Tree Creative</a>
<nav id="mainNav">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</nav>
</header>
<section id="welcome">
<h1>Designing your world</h1>
<p>One pixel at a time</p>
</section>
<section id="about">
<h2>About us</h2>
<article id="about_info">
<p>Two Trees Creative is a full-service graphic design agency based in Ventura, CA. Our goal is to provide elegant work and unsurpassed customer service to our clients in every way.</p>
<h3>Meet Our Team of Creatives</h3>
<p>Collectively we have over 15 years experience in the graphic design industry, and our services include brand identity development, business cards, brochures, flyers, catalogs, and more. Thank you for considering us for your next project, and we hope to hear from you soon.</p>
</article>
<aside id="about_team">
<div class="row">
<div class="image">
<img src="_images/team/alex_morrales.jpg" alt="Alex Morrales" width="150" height="150">
<p>Alex Morrales</p>
</div>
<div class="image">
<img src="_images/team/david_kim.jpg" alt="David Kim" width="150" height="150">
<p>David Kim</p>
</div>
<div class="image">
<img src="_images/team/jenny_tabers.jpg" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
</div>
<div class="row"></div>
</aside>
</section>
<footer>
<p>Photoshop adapted from www.lynda.com - Photoshop CC for Web Designed by Justin Seeley</p>
</footer>
</div>
</body>
</html>
For mystyle.css code, under about_team id element i need to code something in order for the 3 box to be align in horizontally.
#wrapper {
max-width: 1280px;
margin: auto;
}
/*header*/
header {
background-color: white;
width:100%;
height: 165px;
text-align: center;
margin-top: 60px;
}
#logo {
background: url(../_images/ttc_logo.png) no-repeat;
width: 85px;
height: 85px;
margin: auto;
margin-bottom: 0px;
display: block;
text-indent: -9999px;
}
#welcome
{
background: url(../_images/banner.jpg);
width:100%;
height:650px;
overflow:hidden;
text-align:center;
color:white;
vertical-align:middle;
}
#welcome h1
{
font-size:4em;
font-family:'Adobe Garamond , serif';
padding-top:200px;
text-transform:uppercase;
}
#welcome p
{
font-size:3em;
font-family:'Adobe Garamond , serif';
font-style:italic;
font-weight:bold;
}
#about
{
margin:auto;
height:550px;
background-image:url(../_images/tree1.gif), url(../_images/tree1.gif);
background-position:-150px, 115%;
background-repeat:no-repeat, no-repeat;
}
#about h2
{
text-align:center;
text-transform: uppercase;
font: 3em 'Adobe Garamond, serif';
font-weight:bold;
padding-top:50px;
margin-bottom:25px;
color:rgb(82, 71,65);
}
#about h3
{
font:36px Arial, sans-serif;
margin-top:60px;
margin-bottom:10px;
color:rgb(134,118,92);
}
#about_info{
float:left;
margin: 0 auto;
padding-top:37px;
width:40%;
height:400px;
padding-left:125px;
}
#about_team
{
float:left;
margin: auto;
height:400px;
padding-top:37px;
padding-left:20px;
}
#mainNav{
width: 680px;
margin: auto;
}
#mainNav ul li {
margin: 0;
padding: 0;
list-style-type: none;
display: inline;
}
#mainNav li a:link{
text-align: center;
display: block;
float: left;
width: 110px;
text-decoration: none;
text-transform: uppercase;
color: #5b866b;
margin: 20px 20px;
height: 20px;
padding: 5px;
border-radius: 5px;
}
#mainNav ul li a:hover,
#mainNav ul li a:focus
{
background: rgb(185,140,72);
color: white;
box-shadow: 2px 3px 4px 0px #CC9933;
}
footer{
background-color: #dee7e1;
text-align:center;
height:20px
padding:20px;
clear:both;
}
https://jsfiddle.net/ow6hc90f/1/
Just add
.image {
float: left;
}
and remove the float from this
#about_team {
/* float:left; */
margin: auto;
height:400px;
padding-top:37px;
padding-left:20px;
}
You can use CSS Flexbox. Make your three .image divs wrap under a parent div (.image-block - in my case).
Look at this Codepen
Something like this:
.image-block {
display: flex;
justify-content: center;
}
.image {
margin-right: 10px;
text-align: center;
}
<div class="image-block">
<div class="image">
<img src="http://placehold.it/200x200" alt="Alex Morrales" width="150" height="150">
<p>Alex Morrales</p>
</div>
<div class="image">
<img src="http://placehold.it/200x200" alt="David Kim" width="150" height="150">
<p>David Kim</p>
</div>
<div class="image">
<img src="http://placehold.it/200x200" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
</div>
Hope this helps!
Add width: 3 times (imageWidth+margin) into #about_team and add width: 150px and display: inline-block into .image. font-size: 0 in #about_team is to remove space between inline-block element, and you need to restore the size in the .image.
#about_team {
width: 480px;
float: right;
font-size: 0;
}
#about_team .image{
display: inline-block;
width: 150px;
margin-right: 10px;
font-size: 14px;
}
<aside id="about_team">
<div class="row">
<div class="image">
<img src="https://avatars3.githubusercontent.com/u/1024025?v=3&s=400" alt="Alex Morrales" width="150" height="150">
<p>Alex Morrales</p>
</div>
<div class="image">
<img src="https://pbs.twimg.com/profile_images/558109954561679360/j1f9DiJi.jpeg" alt="David Kim" width="150" height="150">
<p>David Kim</p>
</div>
<div class="image">
<img src="http://a5.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE5NDg0MDU0NTIzODQwMDE1.jpg" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
<div class="image">
<img src="http://a4.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE1ODA0OTcxNjk3OTMxNzg5.jpg" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
<div class="image">
<img src="http://i142.photobucket.com/albums/r96/thisdayinmusic/PaulMcCartneyHandsomePaul.png" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
<div class="image">
<img src="http://static.giantbomb.com/uploads/original/8/84561/1465721-georgeharrison.jpg" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
</div>
</aside>
Sorry if I posted something similar to other questions, but actually I needed solution. Well what I am trying to do is am creating gallery of images. So I have images of 200px, each image is block. So in order to center those image according to screen-sizes I am trying to wrap those images inside other div(i.e. inline-block). But its not ready to move in center.
I also want to mention that I am using this within a container.
.gallery{
display:inline-block; /* I am not sure what to do here */
}
.thumbnail{
width:200px;
height:200px;
border:1px solid #aaa;
border-radius:5px;
display:block;
}
.thumbnail img{
width:100%;
height:100%;
border:5px solid white;
border-radius:5px;
}
.gallery-item{
float:left;
margin:10px;
}
.clearfix:after{
clear:both;
}
.clearfix:after, .clearfix:before{
display:table;
content: " ";
}
.clearfix:after{
content:" ";
height:10px;
}
<div class="gallery">
<div class="thumbnail gallery-item">
<img src="images/slide1.jpg" />
</div>
<div class="thumbnail gallery-item">
<img src="images/slide1.jpg" />
</div>
<div class="thumbnail gallary-item">
<img src="images/slide1.jpg" />
</div>
<div class="thumbnail gallery-item">
<img src="images/slide1.jpg" />
</div>
<span class="clearfix"></span>
</div>
Don't use float property if you want elements to be centered.
.gallery {
font-size: 0; /*fix for white space */
text-align: center;
}
.thumbnail {
display: inline-block;
margin: 10px;
width: 200px;
height: 200px;
border: 1px solid #aaa;
border-radius: 5px;
box-sizing: border-box;
}
.thumbnail img {
max-width: 100%;
height: auto;
border: 5px solid white;
border-radius: 5px;
box-sizing: border-box;
}
<div class="gallery">
<div class="thumbnail">
<img src="http://placehold.it/200x200" />
</div>
<div class="thumbnail">
<img src="http://placehold.it/200x200" />
</div>
<div class="thumbnail">
<img src="http://placehold.it/200x200" />
</div>
<div class="thumbnail">
<img src="http://placehold.it/200x200" />
</div>
</div>
JSFiddle: http://jsfiddle.net/ntbh1rmk/
well since i need 50 reputation to comment (very stupid restriction in my opinion).. i was going to ask why you have 100% for width and height, then add 5px padding to it? isn't that like making it 100% + 10PX?
.thumbnail img{
width:100%;
height:100%;
border:5px solid white;
border-radius:5px;
maybe it's just how i'm being taught... (i'm in CSS class now).. but thats always been a bad thing.
I have a div that holds content in it that has a relative position and is restricted by 980px width. I'm trying to give this div a background image banner that will spread out 100% width of the screen. I can't seem to figure it out.
The div that I'm trying to throw the image is #design-background that should be the background of div #bottom-content
Thanks in advance:
JSFiddle: https://jsfiddle.net/74j0o4mx/
<div id="container-content">
<div id="content">
<div id="all-content">
<div id="top-content">
<div id="top-left-content">
<div class="content-body" role="main" aria-label="Main Content Area"><div class="editorContent"><div style="font-family: ralewayregular; font-size: 120%; color: #a5610b; line-height: 200%; text-align: justify;">
<p>stuff</p>
</div></div><div style="clear:both;"></div></div> </div>
<div id="top-right-content">
<p>stuff</p>
</div>
<div id="bottom-content">
<div id="design-background">
</div>
<div id="bottom-left-content">
<div id="bottom-left-top">
<a href="#">
<img src="/images/layout/layoutImg4.jpg" alt="" width="304" height="194"> <h3>EXAMPLE</h3>
</a>
</div>
<div id="bottom-left-bottom">
<a href="#">
<img src="/images/layout/layoutImg3.jpg" alt="" width="304" height="195"> <h3>EXAMPLE</h3>
</a>
</div>
</div>
<div id="bottom-center-content">
<div id="bottom-center">
<a href="#">
<img src="/images/layout/layoutImg5.jpg" alt="" width="311" height="406"> <h3>EXAMPLE</h3>
</a>
</div>
</div>
<div id="bottom-right-content">
<div id="bottom-right-top">
<a href="#">
<img src="/images/layout/layoutImg1.jpg" alt="" width="308" height="195"> <h3>EXAMPLE</h3>
</a>
</div>
<div id="bottom-right-bottom">
<a href="#">
<img src="/images/layout/layoutImg2.jpg" alt="" width="308" height="195"> <h3>EXAMPLE</h3>
</a>
</div>
</div>
</div>
<div id="bottom-text-content">
<p>stuff</p>
</div>
</div>
</div>
</div>
</div>
CSS:
#design-background{
position:absolute;
height:350px;
top:50%;
left:0px;
right:0px;
margin-top: -175px;
background: url('../images/background-dec.jpg');
}
#content{
position:relative;
margin: 0 auto;
left:0;
right:0;
width:980px;
}
#all-content{
display:block;
position:relative;
width:98.9%;
margin: 0 auto;
}
#top-content{
margin: 0 0 0 13px;
position:relative;
display:block;
width:98.9%;
min-height: 165px;
}
#top-left-content{
position:relative;
width:65%;
left:0;
margin-top: 10px;
}
#top-right-content{
position:absolute;
right:0;
top:0;
width:35%;
margin-top: -30px;
text-align: right;
}
#bottom-content{
position:relative;
display:block;
text-align:right;
height:407px;
}
#bottom-left-content{
width:33%;
position:relative;
float:left;
height:407px;
margin-right:3.5px;
}
#bottom-center-content{
position:relative;
width:33.33%;
float:left;
height:407px;
text-align: center;
}
#bottom-right-content{
position:relative;
float:right;
width:33%;
height:407px;
}
#bottom-left-top{
position:absolute;
right:0;
}
#bottom-left-bottom{
position:absolute;
bottom:0px;
right:0;
}
#bottom-right-top{
position:absolute;
right:0;
}
#bottom-right-bottom{
position:absolute;
bottom:0px;
right:0;
}
#bottom-center{
position:absolute;
margin: 0 0 0 12px;
left:0;
right:0;
}
#bottom-text-content{
position:relative;
display:block;
width:100%;
text-align:center;
font-family: Semibold;
color: rgb(165,97,11);
font-size:300%;
vertical-align: middle;
}
#content h3{
display:none;
}
#content a:hover h3{
color:#FFF;
display:block;
position: absolute;
top:50%;
margin-top: -25px;
width:100%;
text-decoration: none;
font-family: ralewayregular;
height:50px;
background-color: rgba(0,0,0,0.7);
text-align: center;
padding-top:25px;
font-size: 200%;
}
#container-content{
position:relative;
margin: 0 auto;
width:100%;
height:100%;
background-color:#FFF;
min-height: 680px;
}
The key is to make sure the parent of #design-background has a position relative value and set to 100% width. Read this to learn how it works.
Important properties:
#content {
position:relative;
}
#all-content {
width:980px;
margin: 0 auto;
}
See the updated demo here - http://jsfiddle.net/rrwjkb3g/
(I have everything set to 0)(Note that the images height is unknown and they are centered)
This is the code:
<div id="ctl06_ImagesPanel">
<div style=" padding: 0px; margin: 0px; width:300px; display:table-cell; vertical-align: middle; background:Blue;">
<div style=" display:inline-block; padding: 0px; margin: 0px;">
<img src="Media/2/M213907891711W.jpg" id="ctl06_ctl00_MediaImage" style="margin:0px;" alt="Option 1" />
</div>
</div>
<div style=" padding: 0px; margin: 0px; width:300px; display:table-cell; vertical-align: middle; background:Blue;">
<div style=" display:inline-block; padding: 0px; margin: 0px;">
<img src="Media/2/M213907891712W.jpg" id="ctl06_ctl01_MediaImage" style="margin:0px;" alt="Option 2" />
</div>
</div>
</div>
You could add vertical-align:top to the img elements:
EXAMPLE HERE
#ctl06_ImagesPanel img {
vertical-align:top;
}
The default value of the vertical-align property is baseline, that's why you were getting a ~2px space at the bottom of the img elements.
I am new to webdesign and I thought I grasped the idea on how to make a layout. I am having a hard time positioning the images correctly in my layout to make a proper header.
The image posted is what i am trying to achieve. I posted the code I wrote which is totally wrong. Any help is appreciated! -thank you
http://img220.imageshack.us/img220/7097/helpcopy.jpg)
HTML
<div id="container">
<div id= "header">
<div id="leftimage">
<img src="images/1.jpg" alt="" width="604" height="85" />
</div>
<div id ="rightimage">
<div id="verticalimage">
<img src="images/2.jpg" alt="" width="29" height="85" />
</div>
<div id="horizontalimages">
<img src="images/3.jpg" alt="" width="182" height="32" />
<img src="images/4.jpg" alt="" width="182" height="22" />
<img src="images/5.jpg" alt="" width="182" height="31" />
</div>
</div>
</div>
</div>
CSS
body{
background: white;
font-family: Arial, Helvetica, sans-serif;
color:#7d806c;
font-weight: bold;
}
#container{
width: 1000px;
margin:0 auto;
outline: 1px dashed red;
}
#leftimage{
width:604;
height: 85;
float: left;
}
#rightimage{
width: 211;
height: 85;
float: right;
margin: 25px 0 0 0;
}
#verticalimage{
width:29;
height:85;
float:left;
}
#horizontalimages{
width:182;
height:85;
float: right;
}
There is no style for header so its not aligning the div properly. and px is missing in "horizontalimages" class. Add the below style in your css
#header {position:relative; background-color:#FFF}
#horizontalimages{width:182px; height:85px; float: right;}
I am just scripting this out by looking at your layout. Hopefully it will help you to figure out how to manage the floats. Output: http://jsfiddle.net/P3Sjk/
<html>
<body>
<style type="text/css">
* { margin:0px; padding:0px; }
div.header{ width:1000px; }
div.w604 { float:left; width:604px; height:85px; background-color:#65FF00; }
div.w29 { float:right; width:29px; height:85px; background-color:#000000 }
div.w182 { float:right; width:182px; height:85px; }
div.h32 { width:182px; height:32px; background-color:#FFD800; }
div.h22 { width:182px; height:22px; background-color:#FF4E00; }
div.h31 { width:182px; height:31px; background-color:#6601FF; }
</style>
<div class="header">
<div class="w604"></div>
<!---whitespace-->
<div class="w182">
<div class="h32"></div>
<div class="h22"></div>
<div class="h31"></div>
</div>
<div class="w29"></div>
</div>
</body>
</html>
You forgot to add px to the end of your CSS width/height declarations.
And with some reformatting of the floats, I came up with this:
http://jsfiddle.net/4gddY/.
Still trying to figure out the problem with the spacing between the horizontal images.
EDIT: Setting the images to display: block worked. http://jsfiddle.net/4gddY/1/
Here is the CSS:
body{
background: white;
font-family: Arial, Helvetica, sans-serif;
color:#7d806c;
font-weight: bold;
}
#container{
width: 1000px;
margin:0 auto;
outline: 1px dashed red;
}
#leftimage{
width:604px;
height: 85px;
float: left;
}
#rightimage{
width: 211px;
height: 85px;
margin: 25px 0 0 auto;
}
#verticalimage{
width:29px;
height:85px;
float:left;
}
#horizontalimages{
width:182px;
height:85px;
margin-left: auto;
}
img {
display: block;
}
i dont know how u want to display your header images
but on my guesses
you have try this
<div id="horizontalimages">
<img src="Images/image3.jpg" alt="" width="182" height="32" /><br />
<img src="Images/image4.jpg" alt="" width="182" height="22" /><br />
<img src="Images/image5.jpg" alt="" width="182" height="31" /><br />
</div>