Place an image infront of a text - html

I have a title with html code:
<div id="site-title">
<a rel="home" > book Journey</a>
</div>
No i want to insert a small pic infront of this book journey, how can i do it.

You can use <span> inline elements to work with text along with images
HTML
<div id="site-title">
<a rel="home" ><img src="imageurl"/><span>book Journey</span></a>
</div>
CSS
img,span{
vertical-align:middle;
}
Fiddle

Why don't you use an Image tag for the link.
<img src="/path_to_img"/><span>book journey</span>

Try this:
<div id="site-title">
<a rel="home" >
<img style="float:left;" src="path-of-your-image/image.jpg" />
book Journey
</a>
</div>

Here is the answer you asked for ,
http://jsfiddle.net/Manjuboyz/vJS4m/133/
<div id="first">
<div id="text"> Book Journey
</div>
<div id="img"><img src="~/Images/doctor-landing.png" style="height: 100%; width: 100%;" </div>
</div>
CSS for above
#first{
height:35px;
width:150px;
border:1px solid brown;
}
#text{
height:30px;
width:100px;
border:1px solid black;
float:left;
}
#img{
height:30px;
width:30px;
margin-left:110px;
border:1px solid teal;
}
NOTE:
Change the image to left or right as you needed
UPDATE
Responsive Screen

Related

Build responsive button with image, text and a link using css

I tried several things but I am out of luck. I need to build a button containing an image and text over a button background image. Also, clicking anywhere inside the button should redirect to a page, for example, google.com. This is how the button should look like
The challenge I am having is that when the button text changes or when the screen size changes, the alignment of the image and the text gets messed up. I want to wrap the button text if it is too large. How do I wrap the button text and still align everything correctly? Also, I want the button width to be the same as I have to build multiple buttons of the same size with varied texts and images. Thank you so much. A quicker solution will be appreciated as I am anxious to see what I am doing wrong. Here is the code I have so far: JSFiddle
<a href="https://www.google.com" style="color: white !important; background-color: #7FFF00;padding: 25px;width: 50px;">
<span style="margin-bottom: 5%;">
<img src="http://placehold.it/30x30" height:100%; style="display: inline-block;" width="30" height="30" />
<span style="display: inline-block;">
<b><font size ="2" color="BLACK" face="Arial">CLICK ON THE IMAGE TO VIEW MORE DETAILS ABOUT THE ITEM </font> </b>
</span>
</span>
</a>
img{
width:30px;
height:30px;
}
a{
text-decoration:none;
color:black;}
#img{
float:left;
}
#img,#text{
display:inline;
}
#main{
margin-top:20px;
width:250px;
border:2px solid black;
border-radius:10px;
background:yellowgreen;
}
#container{
margin:15px;
}
div.clickable {
position:relative;
}
div.clickable #mainlink {
position:absolute;
width:100%;
height:100%;
}
<div class="clickable">
<a href="www.google.com" id="mainlink">
<div id="main">
<div id="container">
<div id="img">
<img src="http://oer.nios.ac.in/wiki/images/thumb/4/47/Thumpsup.png/200px-Thumpsup.png"/>
</div>
<div id="text">
<span>Click on the image to view more about the item</span>
</div>
</div>
</div>
</a>
</div>

How to place images next to each other

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

Centering Images Within My HTML Code

I am attempting to center images located in my HTML code as they are currently all showing to the left side. This is within the program Infusionsoft, so not sure if it's just the system that won't let me center with everything I have tried, or if I'm just doing it incorrectly. Any push in the right direction would be helpful.
<div style="width:1000px; height:1000px; border:0px; padding:0px;">
<a href="ImageLocation1">
<img alt="single.png" src="ImageSource1" style="width:280px; height:614px; border:0px solid blue; float:left;" />
</a>
<a ImageLocation2">
<img alt="Corporate.png"src="ImageSource3" style="width:280px; height:614px; border:0px solid blue; float:left;" />
</a>
<a ImageLocation3">
<img alt="partner.png" src="ImageSource2" style="width:280px; height:614px; border:0px solid blue; float:left;" />
</a>
</div>
There are two different ways of centering your images, individually, or as a group.
Individual:
<div style="width:200px; height:200px; border:2px solid red; padding:0px;">
<a href="ImageLocation1">
<img alt="single.png" src="ImageSource1" style="width:48px; height:61px; border:0px solid blue; display:block; margin:0 auto;" />
</a>
<a href="ImageLocation2">
<img alt="Corporate.png" src="ImageSource3" style="width:48px; height:61px; border:0px solid blue; display:block; margin:0 auto;">
</a>
<a href="ImageLocation3">
<img alt="partner.png" src="ImageSource2" style="width:48px; height:61px; border:0px solid blue; display:block; margin:0 auto;"/>
</a>
</div>
Added display: block and margin: 0 auto to each image
Group:
<div style="width:200px; height:200px; border:2px solid red; padding:0px;text-align:center">
<a href="ImageLocation1">
<img alt="single.png" src="ImageSource1" style="width:48px; height:61px; border:0px solid blue;" />
</a>
<a href="ImageLocation2">
<img alt="Corporate.png" src="ImageSource3" style="width:48px; height:61px; border:0px solid blue;">
</a>
<a href="ImageLocation3">
<img alt="partner.png" src="ImageSource2" style="width:48px; height:61px; border:0px solid blue;" />
</a>
</div>
Added text-align: center to the wrapper
Fiddle: https://jsfiddle.net/4mnLLxz7/
I changed your height and widths to better present the fiddle, you only need to edit those back to what they were originally.
If you do not wish to use display: block then you can look into flex which is a great tool.
CSS | Flex

image not resizing in twitter bootstrap responsive page design

I have a web page which is designed using twitter bootstrap along with it's responsive css inclusion to make everything responsive on different window sizes.But the image in the following codes not re-sizing itself when browser resized, so is not showing responsiveness
<div class="container-fluid">
<div class="row-fluid">
<div class="span"> <div class="media">
<img class="mod-picture" src="images/picture.jpg" alt="post picture" /> <div class="media-container"><a class="link-name" href="#" target="_blank">media name</a></div>
</div></div></div></div>
In css file styles are -
.media-link
{
float:left;
border:1px solid #ccc;
display:inline-block;
color:#3B5998;
cursor:pointer;
margin-right:5px;
}
.mod-picture{
margin-right:10px;
border:0;
display:block;
margin:3px;
}
but if i remove float:left; and display:inline-block; styles from media-link class then image is resizing on browser window size changes.But i can't remove these two properties because next content with class "media-container" need to be appear on right.I tried in many ways like adding float:left in the div before link but failed.Please suggest me.
If you are using bootstrap 3, then you may need to add the class 'img-responsive' to your 'img' tag.
You can take styles from Bootstrap 3 and apply for your code:
<a href="http://facebook.com" target="_blank" class="media-link">
<img class="mod-picture" src="images/picture.jpg" alt="post picture" />
</a>
.media-link{
//nothing styles
}
.mod-picture{
// max width of image
max-width: 50%;
float: left;
display: block;
border:1px solid #ccc;
}
If you are using bootstrap 3 which you should. Then just add class img-responsive to img tag. and That's all to make it responsive.
Here is CDN link for bootstrap3 css. You don't even need to add bootstrap-responsive css.
//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"
In case bootstrap 2.3 existing problem use this-
<div class="container-fluid">
<div class="row-fluid">
<div class="span-12">
<div class="media">
<a href="http://facebook.com" target="_blank" class="media-link">
<img class="mod-picture" src="images/picture.jpg" alt="post picture" />
</a>
<div class="media-container">
<a class="link-name" href="#" target="_blank">media name</a>
</div>
</div>
<div style="clear:both"></div>
</div>
</div>
</div>
.mod-picture{
width:40%;
padding:5%;
max-width: 200px;
height:auto;
float:left;
}
.media-container{
display:inline-block;
}

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