Link to home
Start Free TrialLog in
Avatar of Brian
BrianFlag for United States of America

asked on

Image wrap around text

Hello EE,

I have the following structure for my HTML markup below. I need to have an image for certain <li> elements. I would like to add a padding-right to those images and push the content to the right if possible. This does not seem to work for me though. Thanks in advance!!

HTML:

            <div id="services">
                <div id="sis">
                    <h1>Backpack | <b>SIS</b></h1>
                    <ul>
                        <li><b>Managing student information efficiently.</b></li>
                        <img src="Images/image-test.png" /><li>Backpack manages all student and school information in one central place, so administration is easy.</li>
                        <li><b>Powerful reporting functionality.</b></li>
                        <img src="Images/image-test.png" /><li>Performance charts for grades, attendance, class, and school performance can easily be generated, and compared to other classes and schools.</li>
                        <li><b>Affordable solution.</b></li>
                        <img src="Images/image-test.png" /><li>While Backpack can be installed on site, it is also vailable as a hosted service, reducing the cost of up front investments. In either case, there are no upfront investments.</li>
                    </ul>
                </div>
                <div id="community">
                    <h1>Backpack | <b>Community</b></h1>
                    <ul>
                        <li><b>Our social network brings familes together.</b></li>
                        <li><img src="Images/image-test.png" class="image" />Students, parents, and teachers all log into the same network, making communication easy, and increasing engagement.</li>
                        <li><b>Built with security and safety in mind.</b></li>
                        <li><img src="Images/image-test.png" class="image" />Backpack is “fenced off”, so only approved parties have access. Everything is encrypted and kept secure.</li>
                        <li><b>Better transparency and accountability.</b></li>
                        <li><img src="Images/image-test.png" class="image" />Parents can view all of their child’s information and receive email updates about their performance, so there’s no need to send notes home.</li>
                    </ul>
                </div>
            </div>


#content #services
{
    width: 960px;
    padding-top: 20px;
    padding-bottom: 20px;
}


#content #services #sis
{
    float: left;
    width: 440px;
    padding-left: 20px;
    padding-right: 20px;
}

#content #services #sis h1
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    text-align: center;
}

#content #services #sis h1 b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: normal;
    color: #53a4bb;
    text-align: center;
}

#content #services #sis ul
{
    list-style: none;
    padding-top: 20px;
    width: 400px;
}

#content #services #sis ul li
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #000;
}

#content #services #sis ul li b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #53a4bb;
}

#content #services #sis ul li .image
{
    padding-right: 15px;
}

#content #services #community
{
    float: right;
    width: 440px;
    padding-left: 20px;
}

#content #services #community h1
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    text-align: center;
}

#content #services #community h1 b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: normal;
    color: #53a4bb;
    text-align: center;
}

#content #services #community ul
{
    list-style: none;
    padding-top: 20px;
    width: 400px;
}

#content #services #community ul li
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #000;
    padding-bottom: 10px;
}

#content #services #community ul li b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #53a4bb;

Open in new window

Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Try using margin-right instead.
Give each of the <img> tags an align="left".  You may also have to text-align:left your #content #services #community ul li for older browsers.
Avatar of Brian

ASKER

Hi xmediaman,

Ok, I noticed when I tried to add an image inside an <li> element that I get a notice that it's not allowed to add this element inside of an <li>. I attached a screenshot of what I'm trying to accomplish.

 User generated image
Avatar of Brian

ASKER

Hi LZ1,

Sorry, posted this before your reply. Please see what I'm trying to accomplish with the image above.
Something like this then?

You should structure your HTML a little differently so you have better control over each element.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>

#content #services
{
    width: 960px;
    padding-top: 20px;
    padding-bottom: 20px;
}


#content #services #sis
{
    float: left;
    width: 440px;
    padding-left: 20px;
    padding-right: 20px;
}

#content #services #sis h1
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    text-align: center;
}

#content #services #sis h1 b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: normal;
    color: #53a4bb;
    text-align: center;
}

#content #services #sis ul
{
    list-style: none;
    padding-top: 20px;
    width: 400px;
}

#content #services #sis ul li
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #000;
}

#content #services #sis ul li b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #53a4bb;
}

#content #services #sis ul li .image
{
    padding-right: 15px;
}

#content #services #community
{
    float: right;
    width: 440px;
    padding-left: 20px;
}

#content #services #community h1
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    text-align: center;
}

#content #services #community h1 b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: normal;
    color: #53a4bb;
    text-align: center;
}

#content #services #community ul
{
    list-style: none;
    padding-top: 20px;
    width: 400px;
}

#content #services #community ul li
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #000;
    padding-bottom: 10px;
    clear:both;
    float:left;
}


#content #services #sis ul li b{clear:right;float:left;}
#content #services #sis ul li img{ float:left;display:inline; text-align:left;margin-right:10px;height:88px;line-height:15px;}
#content #services #sis ul li {float:left;}
#content #services #sis ul li .description{float:left;clear:right;width:260px;}


#content #services #community ul li b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #53a4bb;
}
</style>


</head>

<body>
<div id="content">
<div id="services">
                <div id="sis">
                    <h1>Backpack | <b>SIS</b></h1>
                    <ul>
                        <li><b>Managing student information efficiently.</b></li>
                        <li>Backpack manages all student and school information in one central place, so administration is easy.</li>
                        <li>
				    		<img src="images/ee.png" class="image" align="left" />
						<b>Powerful reporting functionality.</b>
						<div class="description"> 
							Performance charts for grades, attendance, class, and school performance can easily be generated, and compared to other classes and schools.
						</div>
					</li>
                        <li></li>
                        <li><b>Affordable solution.</b></li>
                        <li>While Backpack can be installed on site, it is also vailable as a hosted service, reducing the cost of up front investments. In either case, there are no upfront investments.</li>
                    </ul>
                </div>
                <div id="community">
                    <h1>Backpack | <b>Community</b></h1>
                    <ul>
                        <li><b>Our social network brings familes together.</b></li>
                        <li>Students, parents, and teachers all log into the same network, making communication easy, and increasing engagement.</li>
                        <li><b>Built with security and safety in mind.</b></li>
                        <li>Backpack is “fenced off”, so only approved parties have access. Everything is encrypted and kept secure.</li>
                        <li><b>Better transparency and accountability.</b></li>
                        <li>Parents can view all of their child’s information and receive email updates about their performance, so there’s no need to send notes home.</li>
                    </ul>
                </div>
            </div>
</div>
</body>
</html>

Open in new window

I would leave your html as is and change your css just a little. Change your css selector for the image to the #community div as such:

#content #services #community ul li .image
{
	margin-right: 15px;
	float: left;
}

Open in new window


and add a "clear: both;" to your li selector

#content #services #community ul li
{
	font-family: Tahoma, Geneva, sans-serif;
	font-size: 12px;
	font-weight: normal;
	color: #000;
	padding-bottom: 10px;
	clear: both;
}

Open in new window

Avatar of Brian

ASKER

LZ1,

How can I center the image so that the image is centered by the <b> and <div id=description>?
Avatar of Brian

ASKER

@ xmediaman,

Your method works the best when using IE6 and IE7.However a few strange things are happening when I test using IE8 and FF3.4.

I'm attaching a screenshot so you can see what happens when a user uses IE8 and FF3.4. IE6 and IE7 are both fine.
ee.png
When you say centered do you mean vertically?
Avatar of Brian

ASKER

@LZ1,

Yes, vertical align. Please see my updated HTML structure. I was not able to use your solution because IE6, IE7, and FF3.4 did not look nice with those browsers. Perhaps though you can help me with this though. For example I need to vertically align center the image below with the content in each <li> tag.

<li><img src="Images/sis-1.png" class="image" alt="Managing student information efficiently." /><b>Managing student information efficiently.</b></li>
<li class="desc">Backpack manages all student and school information in one central place, so administration is easy.</li>

Also, having trouble centering images after each <ul> for <div id-sis> and <div id-community>. I tried text-align = center but that did not work :(


<div id="services">
                <div id="sis">
                    <h1>Backpack | <b>SIS</b></h1>
                    <ul>
                        <li><img src="Images/sis-1.png" class="image" alt="Managing student information efficiently." /><b>Managing student information efficiently.</b></li>
                        <li class="desc">Backpack manages all student and school information in one central place, so administration is easy.</li>
                        <li><img src="Images/sis-2.png" class="image" alt="Powerful reporting functionality." /><b>Powerful reporting functionality.</b></li>
                        <li class="desc">Performance charts for grades, attendance, class, and school performance can easily be generated, and compared to other classes and schools.</li>
                        <li><img src="Images/sis-3.png" class="image" alt="Affordable solution." /><b>Affordable solution.</b></li>
                        <li class="desc">While Backpack can be installed on site, it is also vailable as a hosted service, reducing the cost of up front investments. In either case, there are no upfront investments.</li>
                    </ul>
                    <img src="Images/btn_more-info.png" alt="Backpack SIS" class="btnSISMoreInfo" />
                </div>
                <div id="community">
                    <h1>Backpack | <b>Community</b></h1>
                    <ul>
                        <li><img src="Images/community-1.png" class="image" alt="Our social network brings familes together." /><b>Our social network brings familes together.</b></li>
                        <li class="desc">Students, parents, and teachers all log into the same network, making communication easy, and increasing engagement.</li>
                        <li><img src="Images/community-2.png" class="image" alt="Built with security and safety in mind." /><b>Built with security and safety in mind.</b></li>
                        <li class="desc">Backpack is “fenced off”, so only approved parties have access. Everything is encrypted and kept secure.</li>
                        <li><img src="Images/community-3.png" class="image" alt="Better transparency and accountability." /><b>Better transparency and accountability.</b></li>
                        <li class="desc">Parents can view all of their child’s information and receive email updates about their performance, so there’s no need to send notes home.</li>
                    </ul>
                    <img src="Images/btn_more-info.png" alt="Backpack Community" class="btnCommunityMoreInfo" />
                </div>
            </div>

Open in new window

#content #services
{
    padding-top: 20px;
    padding-bottom: 20px;
}

#content #services #sis
{
    float: left;
    width: 410px;
    padding-left: 30px;
}

#content #services #sis h1
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    text-align: center;
}

#content #services #sis h1 b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: normal;
    color: #53a4bb;
    text-align: center;
}

#content #services #sis ul
{
    list-style: none;
    padding-top: 20px;
}

#content #services #sis ul li
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: normal;
    color: #000;
    line-height: 1.2em;
}

#content #services #sis ul li b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: bold;
    color: #53a4bb;
}

#content #services #sis ul li .image
{
    float: left;
    margin-right: 10px;
}

#content #services #sis .desc
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: normal;
    color: #000;
    padding-bottom: 20px;
    line-height: 1.2em;
}

#content #services #sis .btnSISMoreInfo
{
    text-align: center;
}

#content #services #community
{
    float: right;
    width: 410px;
    padding-right: 30px;
}

#content #services #community h1
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    text-align: center;
}

#content #services #community h1 b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: normal;
    color: #53a4bb;
    text-align: center;
}

#content #services #community ul
{
    list-style: none;
    padding-top: 20px;
}

#content #services #community ul li
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: normal;
    color: #000;
    line-height: 1.2em;
}

#content #services #community ul li b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: bold;
    color: #53a4bb;
}

#content #services #community ul li .image
{
    float: left;
    margin-right: 10px;
}

#content #services #community .desc
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: normal;
    color: #000;
    padding-bottom: 20px;
    line-height: 1.2em;
}

#content #services #community .btnCommunityMoreInfo
{
    text-align: center;
}

Open in new window

Are you trying to get it to look like the image you posted above in your <a href="https://www.experts-exchange.com/questions/27292996/Image-wrap-around-text.html?cid=1572&anchorAnswerId=36488895#a36488895" target="_self"> a36488895</a>???
Avatar of Brian

ASKER

Correct, I need the image itself to be vertically aligned with the content that it's related to.
And you are expecting to have varying lengths of text right?
What I would personally do is again go back and restructure the HTML to be more semantic, because if you don't, you may have more problems than you bargained for.  For example, each section, like you posted above in the image should be one <li> IMHO.

This is what I mean:

Looks good cross-browser too. :)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
#content #services
{
    padding-top: 20px;
    padding-bottom: 20px;
}

#content #services #sis
{
    float: left;
    width: 430px;
    padding-left: 30px;
}

#content #services #sis h1
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    text-align: center;
}

#content #services #sis h1 b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    font-weight: normal;
    color: #53a4bb;
    text-align: center;
}

#content #services #sis ul
{
    list-style: none;
    padding-top: 20px;
}

#content #services #sis ul li
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: normal;
    color: #000;
    line-height: 1.2em;
    clear:both;
    margin:5px;
    padding:5px;
}

#content #services #sis ul li b
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: bold;
    color: #53a4bb;
}

#content #services #sis ul li .image
{
    float: left;
    margin-right: 10px;
}

#content #services #sis .desc
{
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
    font-weight: normal;
    color: #000;
    padding-bottom: 20px;
    line-height: 1.2em;
}

#content #services #sis .btnSISMoreInfo
{
    text-align: center;
}

</style>
</head>

<body>
	<div id="content">
		<div id="services">
			<div id="sis">
				<h1>Backpack | <b>SIS</b></h1>
				<ul>
					<li>
						<img src="images/ee.png" class="image" alt="Managing student information efficiently." />
						<b>Managing student information efficiently.</b>
						<div class="desc">
							Backpack manages all student and school information in one central place, so administration is easy.
						</div>
					</li>
					<li>
						<img src="images/ee.png" class="image" alt="Powerful reporting functionality." />
						<b>Powerful reporting functionality.</b>
						<div class="desc">
							Performance charts for grades, attendance, class, and school performance can easily be generated, 
							and compared to other classes and schools. 
						</div>
					</li>
					<li>
						<img src="images/ee.png" class="image" alt="Affordable solution." />
						<b>Affordable solution.</b>
						<div class="desc">
							While Backpack can be installed on site, it is also vailable as a hosted service, reducing 
							the cost of up front investments. In either case, there are no upfront investments.
						</div>
					</li>
				</ul>
			</div>
		</div>
	</div>
</body>
</html>

Open in new window

Avatar of Brian

ASKER

Hi LZ1,

If I do that will the image then be vertically aligned with the content in the <li>?
With the sample above, unfortunately no. If you have just a limited amount of content in the description, then yes it would be fine. However if you start adding paragraphs of content, you'll run into alignment issues.  

Let me see if I can get you another example
ASKER CERTIFIED SOLUTION
Avatar of LZ1
LZ1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial