How to place two divs next to each other -HTML/CSS - html

I've been googling this and have found many answers, but none of them work in my situation because one of the divs is a gallery with multiple images. Basically, I'm trying to put an image and another gallery in the center of a page next to eachother.
HTML snippet:
<div class="sides">
<div class="featured-item">
<p class="featured-label">This weeks Featured Item is Mint Chip Cupcakes!</p> <img src="img/mintchip.jpg">
</div>
<div class="sides">
<div class="flexslider">
<ul class="slides">
<li>
<img src="img/1.jpg" alt="A Happy Birthday Mario Cake">
</li>
<li>
<img src="img/2.jpg" alt="A Pizza Hut Cake">
</li>
<li>
<img src="img/5.jpg" alt="A Makeup Cake">
</li>
<li>
<img src="img/6.jpg" alt="A Makeup Cake">
</li>
<li>
<img src="img/156.jpg" alt="A Makeup Cake">
</li>
</ul>
</div>
</div>
</div>
CSS:
.sides {
display: inline-block;
text-align: center;
max-width: 612px;
}
I also tried using each div seperately and using margin-left, margin-right but no luck. The max-width is 612px because that's the max-width of the gallery. I tried setting it to 1000 and it shows a ton of the images very widely.
Result: http://i.imgur.com/se8DwyL.png
One image is on top of the other, and they are on the left side of the screen.

First, you are using the "slides" class name for what seem like unrelated divs. I'd change that; it's only going to cause you grief. Next, the wrapper should have a set width and be centered with an auto margin -
.my-Wrapper-class {
width:960px;
margin:0px auto;
}
Now float the two divs holding your picture and slide show -
.featured-item {
float:left;
}
.flex-slider {
float:right;
}
You can add a margin to either of those until it's spaced to your liking.

Related

Align multiple img in different divs [duplicate]

This question already has answers here:
Align child elements of different blocks
(3 answers)
Closed 2 years ago.
I have 4 pictures that I wish to align, the issue I have is that they are not in the same div and I cannot find a responsive solution.
Depending on the size of the screen, the text may take up to 3 lines and I would like for all of the logos to adapt simultaneously even if their own text does not have as many lines.
This is what I currently have :
The logos are what I would like to align.
This is the HTML :
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="buffer"></div>
<p class="text-center">Mon LinkedIn</p>
<a class="image-link" href="link1">
<img class="image-link img-size" src="assets/img/contact/LinkedIn-Logo.png">
</a>
</div>
<div class="col-sm-3">
<div class="buffer"></div>
<p class="text-center">Mon profil Malt</p>
<a class="image-link" href="link2">
<img class="image-link img-size" src="assets/img/contact/logoMalt.png">
</a>
</div>
<div class="col-sm-3">
<div class="buffer"></div>
<p class="text-center">Mes projets open source</p>
<a class="image-link" href="link3">
<img class="image-link img-size" src="assets/img/contact/so-logo.png">
</a>
</div>
<div class="col-sm-3">
<div class="buffer"></div>
<p class="text-center">Mes contributions open source</p>
<a class="image-link" href="link4">
<img class="image-link img-size" src="assets/img/contact/GitHub_Logo.png">
</a>
</div>
</div>
</div>
And this is the CSS :
.image-link {
display: block;
margin-left: auto;
margin-right: auto;
}
.img-size {
max-width: 100px;
max-height: 20px;
}
.buffer {
padding-top: 40px;
}
I did try to put the text and the logos in different rows but even though it yields a good result on big screens, it does not on small screens ( the text gets separated of the logo )
position your link at the bottom will do the trick for you
.image-link {
position:absolute;
bottom:0;
}
and you can set the max-height for your text container if you want
You can adjust the height of the text (paragraph tag) by auto. If don't help done it by changing auto to 20% - 40%, depending on the size of the screen. You have to check the maximum height but I think 30% would be sufficient according to the text.
.buffer p {
height = 30%
}

Centering Divs on Bootstrap Responsive Grid

I'm using bootstrap grid as shown below and I'm trying to centralize some divs. ( pic). I've tried everything {margin:0 auto; width:50% } etc etc but I can't work it out. It can't be that difficult to centralize some divs. What's the problem here? Please don't mark it as a duplicate. I've been researching the whole day, I just can't work it out.
Thank you
<header data-spy="affix" id="myHeader" class="container row">
<div class="col-sm-4 ">
<div class="centralize">
<a href="http://www.facebook.com" target="_blank">
<img class="logos" src="images/facebook.png" onmouseover="zoomin(this.id)" onmouseout="zoomout(this.id)">
</a>
<a href="http://www.twitter.com" target="_blank">
<img class="logos" src="images/twitter.png" onmouseover="zoomin(this.id)" onmouseout="zoomout(this.id)">
</a>
<a href="http://www.instagram.com" target="_blank">
<img class="logos" src="images/instagram.png" onmouseover="zoomin(this.id)" onmouseout="zoomout(this.id)">
</a>
</div>
</div>
<div class="col-sm-4">
<div class="centralize">
//Other Stuff to be centralized
</div>
</div>
<div class="col-sm-4">
<div class="centralize">
//Other Stuff to be centralized
</div>
</div>
</header>
Actually with {margin:0 auto; width:50%} it should work.
But in your code I see that you are using the .col-sm-4 class on the parent div that only takes 1/3 of the width. It might work with .col-sm-12 instead that takes 100%
To center align the content within the class="centralize" divs, use:
.centralize {
text-align: center;
}

Position of the title in 960gs

Hy. I work with 960gs (12 columns) and I try to put the title after the logo in the bottom part of it. The solution I find doesn't work too good because it place the title under logo.
HTML:
<div id="header" >
<div class="container_12">
<header>
<div class="grid_4">
<a href="index.html" title="Pagina principala - CRCE" rel="home">
<img src="images/CRCE_logo.png" alt="logo CRCE"/>
</a>
</div>
<div id="titlePosition"class="grid_10">
<a href="index.html" title="" rel="home">
<img src="images/titlu_crce.png" alt=""/>
</a>
</div>
</header>
</div>
</div>
CSS:
#header{
background: #798AF7;
background-repeat: repeat-x;
height: 205px;
overflow: visible;
border-bottom: 30px solid #37459D;
display: block;
}
#titlePosition{
position: bottom;
}
The logo is on 4 columns and the title on 10 columns. Also I will put the language chooser(selector) and FB logo in the right top so I think that's a challenge. I've attached an image for details too, see how I want to look at the final header
I don't think you can use the columns in that fashion, it should sum to 12.
Because the logo from first Column overlaps on the second. Make your logo column as just 2 cols and have your title as 10 cols.
<div class="grid-container">
<div class="grid-2 logo-wrapper">
<img class="logo" src="logo.jpg">
</div>
<div class="grid-10">
<!-- Look how the grids can be nested further-->
<div class="grid-container">
<div class="grid-10 text-right"> Language selector</div>
<div class="grid-10 text-right"> Facebook </div>
<!-- You can use top margin -->
<div class="top30px grid-12"> Title</div>
</div>
</div>
</div>
Now set the logo image to absolute position
.logo
{
position:absolute;
left:0;
right:0;
}
Then for the parent around the .logo set it to relative.
.logo-wrapper
{
position:relative;
}
I have given my solution considering pseudo grid system, because i haven't used 960gs - grid system.
General Idea:
You can consider that following 3 element are in different rows occupying 10 columns
language selector
Facebook icon and
Site Title
Tips:
Avoid absolute position for Title as you can achieve it through
nested grids as shown in the above HTML
Use top margin to push the
title further below to the required position.

I am having problems with CSS getting ads to line up

I am building a website and I have three ads towards the bottom of my page. They appear but on there own line. I have tried everything from creating a floating div to removing divs. But I can't seem to figure out what part of the CSS isn't allowing these boxes to be straight across the page.
Here is the code for the three boxes:
<div class="wrapper margin-bot1">
<div class="bg-3">
<div class="indent">
<div class="wrapper margin-bot">
<img src="http://www.webstertoolbox.com/media/wysiwyg/images/page1_img1.png" alt="" />
<img src="http://www.webstertoolbox.com/media/wysiwyg/images/logo_archilume.png" alt="" width="150" height="41" />
</div>
<ul class="ul-1">
<li>Made in USA </li>
<li>Expert Domestic Tech Support</li>
<li>High-end installations</li>
<li>Robust features</li>
</ul>
<a class="button-1 margin-left" href="more.html">Click to Order Now!</a>
</div>
</div>
<div class="bg-3">
<div class="indent">
<div class="wrapper margin-bot">
<img src="http://www.webstertoolbox.com/media/wysiwyg/images/page1_img1.png" alt="" />
<img src="http://www.webstertoolbox.com/media/wysiwyg/images/GenLume-Logo.png" alt="" width="103" height="41" />
<div class="extra-wrap"> </div>
</div>
<ul class="ul-1">
<li><a class="test123" href="moreGEN.html">Quick solutions</a></li>
<li>Turn-key applications</li>
<li>Certified</li>
<li>Competitive pricing</li>
</ul>
<a class="button-1 margin-left" href="moreGEN.html">Click to Order Now!</a>
</div>
</div>
<div class="bg-3">
<div class="indent">
<div class="wrapper margin-bot">
<img src="http://www.webstertoolbox.com/media/wysiwyg/images/page1_img1.png" alt="" />
<div class="extra-wrap">
<h4>DuraLume</h4>
<h5>Series</h5>
</div>
</div>
<ul class="ul-1">
<li>Expert Domestic Tech Support</li>
<li>Made in USA </li>
<li>Custom solutions</li>
<li>On-site Engineers</li>
</ul>
<a class="button-1 margin-left" href="more.html">Click to Order Now!</a>
</div>
</div>
</div>
I can't figure out how to properly show the CSS but you can find the actual site here: http://www.webstertoolbox.com/
If you look below the Big banner you will see an ArchiLume, GenLume and DuraLume boxes that run vertically down the page. I want them to appear across the page.
Can someone please tell me what I did wrong and how to fix it?
Thanks,
Frank G.
Very easy and fast to fix it.
Just change your css file named homeads.css on line 128:
.bg-3
{
background: url(../images/bg-4.png) left top no-repeat;
width: 33%; // Changed this from 100% to 33%
height: 322px; //Changed from 268px to 322px
overflow: hidden;
float: left; // Added the float left
}
Cheers,
Thanos
EDIT: After doing the change above you will need to add a couple more changes to fix a couple of things that will get a bit misaligned.
Such as the right border will not be visible anymore. Below are the changes you will need to do to fix that as well.
On homeads.css line 33:
.main
{
width: 950px; // Reduced this to match with the parent's width
padding: 0;
margin: 0 auto;
position: relative;
}
On sceleton.css line 25:
.grid_1, .grid_2, .grid_3, .grid_4, .grid_5, .grid_6, .grid_7, .grid_8, .grid_9, .grid_10, .grid_11, .grid_12, .grid_13, .grid_14, .grid_15, .grid_16, .grid_17, .grid_18, .grid_19, .grid_20, .grid_21, .grid_22, .grid_23, .grid_24
{
float: left;
display: inline;
//margin-left: 5px; Remove these 2
//margin-right: 5px; Remove these 2
}
EDIT2: The first box is getting pushed down a little bit. That is caused because on the first box you are missing a div <-> on the second and third box you have an extra div inside them.
<div class="wrapper margin-bot">
<img src="http://www.webstertoolbox.com/media/wysiwyg/images/page1_img1.png" alt=""> <img src="http://www.webstertoolbox.com/media/wysiwyg/images/duralume.gif" alt="" width="103" height="41">
<div class="extra-wrap"> </div> // THIS IS THE EXTRA DIV
</div>
You have 2 choices here:
1) Add the div
<div class="extra-wrap"> </div>
to the first box
2) Remove that div from box 2 and 3.
.cms-home class help you do not affect other pages layout. Add in your stylesheets:
.cms-home .wrapper {
overflow: visible; //For big banner
}
.cms-home .bg-3 {
overflow: visible;
width: 33%;
display: inline-block;
}

Random Space - Messed up Alignment

I'm working on my first website and I'm very pleased with my progress thus far, but I've run into an issue.
I'm trying to align a black "block" with the blue block above it. For some reason, there is like a random space right infront of the black bar.
I am using the 960 grid system (16 column variant). Here is an image of the issue I am having: http://gyazo.com/4a9a0ba8b31105f1e95029f9cf878009.png
Here is the code I have. Can anyone understand why I have that random space infront of it?
<div id="banner" class="grid_16">
<div id="socialmedia" class="grid_3 prefix_7">
<img src="images/facebook.gif" alt="facebook icon">
<img src="images/twitter.gif" alt="twitter icon">
<img src="images/youtube.gif" alt="youtube icon">
</div>
<div id="bar" class="grid_16">
</div>
</div>
And then the CSS:
#bar {
height: 20px;
background-color: black;
}