How to place images next to each other - html

Not sure what's wrong with this because currently it's not responding to the CSS. It just overlaps all the images and text on top of each other and the images are original size rather than the 50px by 50px as indicated in the CSS.
HTML:
<p> Connect with Steven on </p>
<div class=socialmedialinks>
<a href="https://www.facebook.com/Established.in.1995" class=links> <img src="FBProfilePic.jpg" alt="Facebook">
</a> Facebook
<a href="http://twitter.com/stevenperkinsii" class=links> <img src="TwitterProfilePic.jpg" alt="Twitter">
</a> Twitter
<a href="https://www.linkedin.com/in/steven-perkins-9319ba93?trk=hp-identity-name" class=links> <img src="LinkedInProfilePic.jpg" alt="LinkedIn">
</a> LinkedIn
<a href="http://www.stevensperkins.wordpress.com/" class=links> <img src="WordPressProfilePic.jpg" alt="WordPress">
</a> WordPress
</div>
CSS:
.socialmedialinks {text-align:justify; width:50px}
.links{
display: inline-block; width:50px; height:50px;
}

Steven do you have an example of the output you're looking for? You've got a wide variety of issues going on here that are creating issues with your output if I understand correctly what you're trying to do.
First and foremost, you don't have any styles constraining the size of the images, you need the following style definition:
.links img {
max-width:50px;
max-height:50px;
}
Regarding positioning of the text relative to the images, you've got structural issues preventing things from displaying the way you want them to. You also need to surround your class names with quotes really, though that's not a factor here. I've reworked your code slightly to make what I think you want, if there are specifics to what I've done that aren't what you're looking for let me know and I'll help you get where you want to be: https://jsfiddle.net/7k5nn1n7/

Is this what you are trying:
<p> Connect with Steven on </p>
<div class="socialmedialinks">
<div class="links"><img alt="Facebooki" src="FBProfilePic.jpg">Facebook</div>
<div class="links"><img alt="Twitter" src="TwitterProfilePic.jpg">Twitter</div>
<div class="links"><img alt="LinkedIn" src="LinkedInProfilePic.jpg">LinkedIn</div>
<div class="links"><img alt="WordPress" src="WordPressProfilePic.jpg">WordPress</div>
</div>
CSS:
.socialmedialinks {
width:100%;
}
.links{
float:left;
padding-left:2%;
}
.links img {
width:50px;
height:50px;
}

You can give each link a class name.
add title="" for the link instead of alt="".
remove the image tags.
you can use the CSS to add the image to the link.
here is the code for html:
here is the CSS:
.socialmedialinks a:link,
.socialmedialinks a:active
.socialmedialinks a:visited{
text-indent: -9999em;
width:50px;
height:50px;
margin-right: 3px;
float: left;
padding:0;
}
.facebook {background: url('FBProfilePic.jpg') no-repeat;}
.twitter{background: url('TwitterProfilePic.jpg') no-repeat;}
.linkedin{background: url('LinkedInProfilePic.jpg') no-repeat;}
.wordpress{background: url('WordPressProfilePic.jpg') no-repeat;}
Please if you have any question let me know. thanks

Try The Following code:
HTML
<p>Connect With Steven on </p>
<h4 class="social">
<img src="facebook.jpg" alt="Facebook">Facebook</h4>
<h4 class="social">
<img src="twitter.png" alt="Twitter">Twitter</h4>
<h4 class="social">
<img src="youtube.png" alt="Youtube">Youtube</h4>
<h4 class="social">
<img src="instagram.jpg" alt="Instagram">Instagram</h4>
CSS
img{
height: 50px;
width: 50px;
margin-right: 4px;
}
h4{
width: 150px;
float:left;
}
Here is the sample Fiddle: Fiddle

Related

<a> Tag not lining up with <img>

I have some really basic HTML and CSS and for some reason the outline of the link is lower than the image itself, but they should line up because the image is inside the tag as below:
The code for this is:
<div id="social">
<img src="images/social/deviantart.png" alt="DeviantArt"/>
<img src="images/social/facebook.png" alt="Facebook"/>
<img src="images/social/flickr.png" alt="Flickr"/>
<img src="images/social/google+.png" alt="Google+"/>
<img src="images/social/linkedin.png" alt="LinkedIn"/>
<img src="images/social/tumblr.png" alt="Tumblr"/>
<img src="images/social/twitter.png" alt="Twitter"/>
<img src="images/social/youtube.png" alt="You Tube"/>
</div>
And the CSS:
#social {
float:left;
width:24px;
}
#social a {
padding:0px;
height:24px;
}
Has anyone got any idea why they are not in line and if so how to get them in line?
Try to add display:inline-block;
#social {
float:left;
width:24px;
display:inline-block;
}

Could someone please advise why the following CSS won't center a paragraph and relating div?

I'm new to HTML and CSS and I'm having difficulty trying to figure out why my CSS won't style my HTML how I think it should. I'd really appreciate some help.
So basically, I have this HTML markup:
<div id="things">
<p>A few things I couldn't live without:</p>
<br><br>
<div class="icons">
<img alt="Google icon" src="images/google.png"/>
<img alt="Wikipedia icon" src="images/wikipedia.png"/>
<img alt="Youtube icon" src="images/youtube.png"/>
<br>
<img alt="Twitter icon" src="images/twitter.png"/>
<img alt="Facebook icon" src="images/facebook.png"/>
<img alt="Whatsapp icon" src="images/whatsapp.png"/>
</div>
</div>
I'd like for the paragraph and the class="icons" to be centered in their div.
I have the following CSS:
#things {
width:31%;
float:left;
}
#things p{
float:left;
margin:3.5% auto 0 auto;
text-align:center;
}
.icons{
float:left;
margin:4% auto 0 auto;
}
Could anyone please advise? Thanks
Check this fiddle
Updated CSS
#things {
width:31%;
margin:0px auto;
text-align:center;
}
#things p{
margin:3.5% auto 0 auto;
}
.icons{
display:inline-block;
}
You will need to remove the float: left; on anything you want centered to begin with.
EDIT
Looks like i was beaten to it in the comments!

How to center this on screen

So as a newbie web developer I am stuck on how to center all 3 images in the middle of the screen. I read up on it and came across margin:auto;. Tried it, didn't work.
This is the CSS:
<style>
.social
{
float:left;
margin:5px;
}
.main_block
{
margin:auto, auto;
}
</style>
This is the HTML:
<div class="main_block">
<img class="social" src="http://lorempixel.com/400/200/"> <a href="#"><img class="social" src="http://lorempixel.com/g/400/200/" alt="Facebook"> <img class="social" src="http://lorempixel.com/400/200/" alt="Google +"> </a>
</div>
Help is much appreciated.
FIDDLE
You need to display the images as block and then apply margin auto
Also your HTML is not correct:
<div class="main_block">
<div class="ib">
<a href="#">
<img class="social" src="http://lorempixel.com/50/50/" />
</a>
<a href="#">
<img class="social" src="http://lorempixel.com/g/50/50/" alt="Facebook" />
</a>
<a href="#">
<img class="social" src="http://lorempixel.com/50/50/" alt="Google +" />
</a>
</div>
</div>
CSS:
.social
{
float: left;
}
.ib {
display: inline-block;
}
.main_block {
text-align: center;
}
I'm not sure if you wanted them to stack over each other, or just to center them.
Stack them over each other
JSFiddle
To stack them over each other, you want to have position:absolute; in the .social tag, that way they won't try to avoid each other. The problem is, margin:auto; won't work then. The only solution I've found to fix this to to set the left: and right: positions to 1%;.
Just center them
JSFiddle
This one is to just center them. You would just want to use margin-left:auto; and margin-right:auto;. With this, you don't need to use position:absolute;.
You have to set a width on the main-block class and remove the comma.
Your style should look something like this:
.main_block
{
width: 40em;
margin:0 auto;
}

Centering and integrating image gallery

HTML/CSS newbie question for you.
I've been stuck on this for awhile. I'm looking to center my image gallery AND also make the padding between the images tighter. I'm thinking I need a container but, I've just been screwing it all up when I try. Any help would be great!
<div id="container" align="center">
<div class="img">
<a href="#">
<img src="#" alt="PIcture1" width="210" height="180">
</a>
<div class="desc">BLAH</div>
</div>
<div class="img">
<a href="#">
<img src="Images/9700_1915630577543_1314909545_n.jpg" alt="oldman" width="210" height="180">
</a>
<div class="desc">BLAH</div>
</div>
<div class="img">
<a href="#">
<img src="#" alt="Picture3" width="210" height="180">
</a>
<div class="desc">BLAH</div>
</div>
<div class="img">
<a href="#">
<img src="#" alt="Picture4" width="210" height="180">
</a>
<div class="desc">BLAH</div>
</div>
</div>
CSS:
#container{
}
div.img
{
margin:5px;
padding: 5px;
border:none;
height:auto;
width:auto;
float:left;
text-align:center;
}
div.img img
{
display:inline;
margin:5px;
border:none;
}
div.img a:hover img
{
border:none;
}
div.desc
{
text-align:center;
font-weight:normal;
width:120px;
margin:5px;
}
It depends on how you want to centre your gallery.
There's a few things that you need to bear in mind. In order to centralise some HTML you need to have a set width of the centralising element.
Here's some code for you to work with:
Create a "centre" class in CSS as follows:
div.centre{
margin:0px auto;
width:800px;
}
Then add it to your container as follows:
<div id="container" class="centre">
The secret to centralisation is in the margin:0px auto;, this is convention of modern web development to centralise content.
Have a look at this code
p.s. don't use align="center" it is depreciated in later versions of HTML. Better to not get into the habit of using it and stick to using CSS classes to centralising things for you.
You should not use align. It is a deprecated property. To center something with a container you need to specify a fixed width and add margin auto.
Ex:
#container {
width:970px;
margin: 0 auto;
}
You can remove the padding on div.img

Embedded div tags - no image load

I think this will be a simple fix for someone out there!
CSS:
#partners .social{
width:219.5px;
padding:10px;
float:left;
}
#partners .social .social-logo{
width:61px;
height:61px;
float:left;
}
#partners .social .social-text{
width:158.5px;
float:left;
}
HTML:
<div class="social">
<div class="social-logo"
<img src="images/fb-silver.png" alt="Find us on Facebook!" />
</div>
<div class="social-text">
Find us on Facebook
</div>
</div>
The image 'fb-silver.png' won't display.
I've tried to load the image outside of these tags and it's fine.
Any ideas?
Cheers!
Close your DIV, also half a pixel doesnt exist i think...
If this doesnt work, the url to your image will be wrong!
<div class="social">
<div class="social-logo">
<img src="images/fb-silver.png" alt="Find us on Facebook!" />
</div>
<div class="social-text">
Find us on Facebook
</div>
</div>