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
Related
This is my code
<a href="https://www.w3schools.com">
<div style="width:200px; border:1px solid black;">
Visit W3Schools.com!
</div>
</a>
My div width is 200PX. But my link is activated right side of the white space. How to activate link only within the div width, ie within 200px?
Depending on what you're trying to do:
<a style="display:inline-block;" href="https://www.w3schools.com"><div style="width:200px; border:1px solid black;">Visit W3Schools.com!</div></a>
Or
<a style="display:block; width:fit-content;" href="https://www.w3schools.com"><div style="width:200px; border:1px solid black;">Visit W3Schools.com!</div></a>
Instead of nesting the div in the a- element, make it its parent.
<div> <div style="width:200px; border:1px solid black;">
Visit W3Schools.com!
</div>
Have fun coding!
Try This:
<div style="width:200px; border:1px solid black;">
<a style="display:flex; width: 100%;" href="https://www.w3schools.com">
Visit W3Schools.com!
</a>
</div>
Trying to create a webpage and I'm having a bit of trouble with the divs. The site that this code is for is similar to the old Myspace, so I can't use CSS in the code. I'm trying to create some tables using DIV, and I'm having some issues.
This is how my page looks so far.
What I'm trying to do is get the gray DIV inside the blue DIV, the blue keeps cutting off, and I don't know what I'm doing wrong. It's probably obvious and I'm probably an idiot for not seeing the problem. I'm not sure what to do about it though.
This is my code:
<center>
<!-- This template was created by the Angry Hobbit -->
<div style="width:540px; background-color:#eefbfd; padding:25px; border:1px solid #d5d6d6;">
<font style="width:485px; display:block; background-color:#eeefef; margin:14px; font-family: times; font-size:39px; font-color:#000000; font-weight:bold;">FIRST MIDDLE LAST</font>
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<font style="width:485;display:block; background-color:#eeefef; margin-top:10px; margin-bottom:10px; font-family:times; font-size:22px; font-weight:lighter; font-style:italic; letter-spacing:-1px;">» some facts</font>
<div style="width:239px; display:inline; float:left; background-color:#eeefef; margin-top:14px; padding:14px;">
<font style="display:block; font-family:times; font-weight:lighter; font-size:15px; font style:bold; border-top:1px dotted #8ca8ac; border-bottom: 1px dotted #8ca8ac;">basic facts</font><br>
<font style="display:block; text-align:left;font-family:times; font-weight:lighter; font-size:9px;">
<b style="background:#d1d3d3;">NAME:</b><br>
<b style="background:#d1d3d3;">AGE:</b><br>
<b style="background:#d1d3d3;">D.O.B:</b><br>
<b style="background:#d1d3d3;">BIRTHPLACE:</b><br>
<b style="background:#d1d3d3;">CURRENT LOCATION:</b><br>
<b style="background:#d1d3d3;">OCCUPATION:</b><br>
<b style="background:#d1d3d3;">ETHNICITY:</b><br>
<b style="background:#d1d3d3;">MARITAL STATUS:</b><br>
<b style="background:#d1d3d3;">SIGNIFICANT OTHER:</b><br>
</div>
`
First thing, you are using CSS it's just inside your HTML. You really should create a .css file and link it with <link>. It would simplify your life and make your code much more readable.
Second, making a div be float remove it from the flow of the page. More info here.
I think this is what you wanted :
<center>
<!-- This template was created by the Angry Hobbit -->
<div style="width:540px; background-color:#eefbfd; padding:25px; border:1px solid #d5d6d6;">
<font style="width:485px; display:block; background-color:#eeefef; margin:14px; font-family: times; font-size:39px; font-color:#000000; font-weight:bold;">FIRST MIDDLE LAST</font>
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<font style="width:485;display:block; background-color:#eeefef; margin-top:10px; margin-bottom:10px; font-family:times; font-size:22px; font-weight:lighter; font-style:italic; letter-spacing:-1px;">» some facts</font>
<div style="width:239px; display:block; background-color:#eeefef; margin-top:14px; padding:14px;">
<font style="display:block; font-family:times; font-weight:lighter; font-size:15px; font style:bold; border-top:1px dotted #8ca8ac; border-bottom: 1px dotted #8ca8ac;">basic facts</font><br>
<font style="display:block; text-align:left;font-family:times; font-weight:lighter; font-size:9px;">
<b style="background:#d1d3d3;">NAME:</b><br>
<b style="background:#d1d3d3;">AGE:</b><br>
<b style="background:#d1d3d3;">D.O.B:</b><br>
<b style="background:#d1d3d3;">BIRTHPLACE:</b><br>
<b style="background:#d1d3d3;">CURRENT LOCATION:</b><br>
<b style="background:#d1d3d3;">OCCUPATION:</b><br>
<b style="background:#d1d3d3;">ETHNICITY:</b><br>
<b style="background:#d1d3d3;">MARITAL STATUS:</b><br>
<b style="background:#d1d3d3;">SIGNIFICANT OTHER:</b><br>
</div>
</div>
You need to close off the second div, remove the float:left and display it as a block. margin-right:auto works well for blocks.
<center>
<!-- This template was created by the Angry Hobbit -->
<div style="width:540px; background-color:#eefbfd; padding:25px; border:1px solid #d5d6d6;">
<font style="width:485px; display:block; background-color:#eeefef; margin:14px; font-family: times; font-size:39px; font-color:#000000; font-weight:bold;">FIRST MIDDLE LAST</font>
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<img src="https://i.imgur.com/tljLCuq.gif" width:150px; height:150px;">
<font style="width:485;display:block; background-color:#eeefef; margin-top:10px; margin-bottom:10px; font-family:times; font-size:22px; font-weight:lighter; font-style:italic; letter-spacing:-1px;">» some facts</font>
<div style="width:239px; display:block; background-color:#eeefef; margin-top:14px; padding:14px;margin-right:auto;">
<font style="display:block; font-family:times; font-weight:lighter; font-size:15px; font style:bold; border-top:1px dotted #8ca8ac; border-bottom: 1px dotted #8ca8ac;">basic facts</font><br>
<font style="display:block; text-align:left;font-family:times; font-weight:lighter; font-size:9px;">
<b style="background:#d1d3d3;">NAME:</b><br>
<b style="background:#d1d3d3;">AGE:</b><br>
<b style="background:#d1d3d3;">D.O.B:</b><br>
<b style="background:#d1d3d3;">BIRTHPLACE:</b><br>
<b style="background:#d1d3d3;">CURRENT LOCATION:</b><br>
<b style="background:#d1d3d3;">OCCUPATION:</b><br>
<b style="background:#d1d3d3;">ETHNICITY:</b><br>
<b style="background:#d1d3d3;">MARITAL STATUS:</b><br>
<b style="background:#d1d3d3;">SIGNIFICANT OTHER:</b><br>
</div>
</div>
Don not use heavy css style in inline-text, use row and column to space not br and do not give div css give it a class with css. and give the blue box some height, 500px covered that area.
.wbpb {
width:540px;
height:500px;
background-color:#eefbfd;
padding:25px;
border:1px solid #d5d6d6;
}
.middle-last{
width:485px;
display:block;
background-color:#eeefef;
margin:14px;
font-family: times;
font-size:39px;
font-color:#000000;
font-weight:bold;"
}
.img{
width:150px;
height:150px;
}
.fact-p{
width:485;
display:block;
background-color:#eeefef;
margin-top:10px;
margin-bottom:10px;
font-family:times;
font-size:22px;
font-weight:lighter;
font-style:italic;
letter-spacing:-1px;"
}
.float-p{
width:239px;
display:inline;
float:left;
background-color:#eeefef;
margin-top:35px;
padding:14px;
}
.font-times{
display:block;
font-family:times;
font-weight:lighter;
font-size:15px;
font style:bold;
border-top:1px dotted #8ca8ac;
border-bottom: 1px dotted #8ca8ac;
}
.block-p{
display:block;
text-align:left;
font-family:times;
font-weight:lighter;
font-size:9px;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
</style>
</head>
<body>
<center>
<div class="wbpb">
<p class="middle-last">FIRST MIDDLE LAST</p>
<img src="https://i.imgur.com/tljLCuq.gif">
<img src="https://i.imgur.com/tljLCuq.gif">
<img src="https://i.imgur.com/tljLCuq.gif">
<div class="fact-p">» some facts</div>
<div class="float-p">
<p class="font-times">basic facts</p><br>
<div class="block-p">
<div class="row">
<div class="column">
<b style="background:#d1d3d3;">NAME:</b>
</div>
<div class="column">
<b style="background:#d1d3d3;">AGE:</b>
</div>
<div class="column">
<b style="background:#d1d3d3;">D.O.B:</b>
</div>
<div class="column">
<b style="background:#d1d3d3;">BIRTHPLACE:</b>
</div>
<div class="column">
<b style="background:#d1d3d3;">CURRENT LOCATION:</b>
</div>
<div class="column">
<b style="background:#d1d3d3;">OCCUPATION:</b>
</div>
<div class="column">
<b style="background:#d1d3d3;">ETHNICITY:</b>
</div>
<div class="column">
<b style="background:#d1d3d3;">MARITAL STATUS:</b>
</div>
<div class="column">
<b style="background:#d1d3d3;">SIGNIFICANT OTHER:</b>
</div>
</div>
</div>
</div>
</body>
</html>
I'm just a complete beginner so most of what I have are combinations from tutorial sites but I'm really stuck on this that it keeps jumping to the top of the page when I try to cycle through next image etc.
Being a totally newby any detailed help is really appreciated?
I don't know where I'm going wrong and have no clue where to even start to fix it?
#gallerywrapper {
width:640px;
height:450px;
margin:0 auto;
position:relative;
font-family:verdana, arial, sans-serif;
}
#gallerywrapper #gallery {
position:absolute;
left:0;
top:0;
height:450px;
width:640px;
overflow:hidden;
text-align:center;
}
#gallerywrapper #gallery div {
width:640px; height:900px;
padding-top:10px;
position:relative;
}
#gallerywrapper #gallery div img {
clear:both;
display:block;
margin:0 auto;
border:0;
}
#gallerywrapper #gallery div h3 {
padding:10px 0 0 0;
margin:0;
font-size:18px;
}
#gallerywrapper #gallery div p {
padding:5px 0;
margin:0;
font-size:12px;
line-height:18px;
}
#gallery .previous{
display:inline;
float:left;
margin-left:80px;
text-decoration:none;
background-color: #ddd;
color: black;
border-radius: 50%;
padding: 8px 16px;
}
#gallery .next{
display:inline;
float:right;
margin-right:80px;
text-decoration:none;
background-color: #FA4B2A;
color: white;
border-radius: 50%;
padding: 8px 16px;
}
<div id="gallerywrapper">
<div id="gallery">
<div id="pic1">
<img src="images/b1.jpg" height="350" width="500" alt="Image 1">
<a class="previous round" href="#pic5" >‹</a>
<a class="next round" href="#pic2" >›</a>
<h3>Botanical Gardens</h3>
</div>
<div id="pic2">
<img src="images/b2.jpg" height="350" width="500" alt="Image 2">
<a class="previous round" href="#pic1">‹</a>
<a class="next round" href="#pic3">›</a>
<h3>Botanical Gardens</h3>
</div>
<div id="pic3">
<img src="images/b3.jpg" height="350" width="500" alt="Image 3">
<a class="previous round" href="#pic2">‹</a>
<a class="next round" href="#pic4">›</a>
<h3>Botanical Gardens</h3>
</div>
<div id="pic4">
<img src="images/b4.jpg" height="350" width="500" alt="Image 4">
<a class="previous round" href="#pic3">‹</a>
<a class="next round" href="#pic5">›</a>
<h3>Botanical Gardens</h3>
</div>
<div id="pic5">
<img src="images/b5.jpg" height="350" width="500" alt="Image 5">
<a class="previous round" href="#pic4">‹</a>
<a class="next round" href="#pic1">›</a>
<h3>Botanical Gardens</h3>
</div>
</div>
</div>
This is due to use of link tag a, as you can see you are specifying ID of element in the href and by default your are scrolling to this element which is in the top of the page.
To avoid this you may use some javascript to prevent the default behavior of these link tags.
You may check these links :
preventDefault() on an <a> tag
How to stop default link click behavior with jQuery
https://css-tricks.com/return-false-and-prevent-default/
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
Thanks for all of your help on my previous question! However, I noticed a small issue- It's not too important, I just wanted to know if there's a way to fix it. As the browser window gets smaller, the images start to overlap. I'd like the images to stop when they're 5px away from each other.
Could someone look over my code and make sure I'm not doing anything wrong with my HTML/CSS?
The HTML is this:
<div class="content">
<div class="listingThumbLine">
<div class="modelListing left">
<a href="modelOne.html">
<img src="modelOne.jpg" alt="Model One" class="modelThumb" id="modelOneThumb">
</a>
<br />
<span class="productThumbName">Model Name</span>
</div>
<div class="modelListing right">
<a href="modelTwo.html">
<img src="modelTwo.jpg" alt="Model Two" class="modelThumb" id="modelTwoThumb">
</a>
<br />
<span class="productThumbName">Model Name</span>
</div>
<div class="modelListing center">
<a href="modelThree.html">
<img src="modelThree.jpg" alt="Model Three" class="modelThumb" id="modelThreeThumb">
</a>
<br />
<span class="productThumbName">Model Name</span>
</div>
</div>
</div>
The CSS is this:
body{
background-image:url('bg.jpg');
background-repeat:repeat-x;
font-family: Arial;
color:#B5B5B5;
text-align:center;
}
.content{
font-size:1.25em;
margin:10px 100px;
}
img.modelThumb{
width:225px;
height:225px;
}
.left{
float:left;
position:relative;
}
.right{
float:left;
position:relative;
}
.center{
float:left;
margin: 0 auto;
}
.modelListing{
width: 33%;
text-align: center;
}