English 中文(简体)
HTML - 基本 HTML - 应用 div id
原标题:Basic HTML - applying div id
 NSString *HTML = [NSString stringWithFormat:@"<html> 
"
                      "<head> 
"
                       "<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">"
                      "<div id= main  style type="text/css"> 
"
                      "body {font-family: "%@"; font-size: %@; color:rgb(30,30,30); line-height: %ipx;}
"
                      "</div> 
"
                      "</head> 
"
                      "<body>%@</body> 
"
                      "</html>", @"helvetica", [NSNumber numberWithInt:[UIFont mainTextFont].pointSize], kWebViewLineSpacing, text];

I m trying to apply a div id main to my content, but I can t figure out how to get it to work. I think the line in question is : "<div id= main style type="text/css"> " but I m not sure how I would adjust it to work?

最佳回答

你在头部部分放一个div,那没用的

NSString *HTML = [NSString stringWithFormat:@"<html> 
"
                  "<head> 
"
                   "<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">"
                  "<style type="text/css"> 
"
                  "body {font-family: "%@"; font-size: %@; color:rgb(30,30,30); line-height: %ipx; -webkit-transform: translate3d(0,0,0); word-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; text-overflow: ellipsis; -webkit-text-size-adjust: none; overflow: hidden;}
"
                  "</style> 
"
                  "</head> 
"
                  "<body><div id="main">My main div</div></body> 
"
                  "</html>", @"helvetica", [NSNumber numberWithInt:[UIFont mainTextFont].pointSize], kWebViewLineSpacing, text];
问题回答

你重新把事情混在一起, 你想要的东西更像

[NSString stringWithFormat:@"<html> 
"
                      "<head> 
"
                       "<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">"
                      "<style type="text/css"> 
"
                      "body {font-family: "%@"; font-size: %@; color:rgb(30,30,30); line-height: %ipx;}
"
                      "</style> 
"
                      "</head> 
"
                      "<body><div id= main >%@</div></body> 
"
                      "</html>", @"helvetica", [NSNumber numberWithInt:[UIFont mainTextFont].pointSize], kWebViewLineSpacing, text];

那条线没有意义 我相信你的意思是:

"<div id= main ><style type="text/css"> 
"

div 作为头部的孩子无效, 应该是身体的孩子 。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签