I am currently using UIWebview for some rich text formatting. I would like to center on the same line a succession of an icon (PNG image) followed by a caption. I am having issue to set up correctly my css style to get the expected effect. It is more a css related question than on Objective C.
So far what I have done is:
NSString* htmlContentString = [NSString stringWithFormat:
@"<html>"
"<style type=\"text/css\">"
"h1 { font-size: 40px;\
font-family: Wisdom Script;\
text-align: center;\
margin-top:5px;\
margin-bottom:0px;\
background-color: black;\
}"
"body { background-color:transparent;\
font-family:Helvetica;\
font-size:14;\
margin-top:0px;\
}"
"#people { background: yellow\
url('tipnbpeople_icon.png')\
no-repeat left center;\
padding-left: 45 px;\
line-height: 40px;\
}"
"#container {\
width: 300px; \
margin:0px auto;\
border:1px dashed #333;\
}"
"</style>"
"<body>"
"<h1>%@</h1>"
"<div id=\"container\">\
<div id=\"people\">Caption1</div>\
<div id=\"people\">Caption2</div>\
<div id=\"people\">Caption3</div>\
</div>"
"</body></html>"\
, noAccentTipName];
The result i am getting is a succession of icon and caption but not on the same line. Any idea?
the
margin:0px autoallows to center a containing block on a page. Here the width I set was fixed. Since it was fixed the content will try to fit within the fixed width and is displayed in multiple lines. What i need to use instead is to use the text-align for the container div.Here is the code i finally use:
This displays 3 icons with the corresponding caption on the same line.