Maison >interface Web >tutoriel HTML >CSS 文本上下标_html/css_WEB-ITnose
public string GetHtml(object obj) { string result = ""; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("{.*,.*,.*}"); string matchResult = regex.Match(obj.ToString()).ToString(); if (string.IsNullOrEmpty(matchResult)) { result = obj.ToString(); } else { string[] strs = matchResult.Replace("{", "").Replace("}", "").Split(','); result = "<table style=\"padding:0px;margin:0px;line-height: 4px;border:none;border-width:0px;\"><tr>"; result += "<td style=\"padding:0px;margin:0px;text-align: right;width:50%; line-height: 10px;border:none;border-width:0px;\" rowspan=\"2\"><span>" + strs[0] + "</span></td>"; result += "<td style=\"padding:0px;margin:0px;text-align: left; line-height: 10px;border:none;border-width:0px;\"><span style=\"vertical-align:super; color:red; font-size:9px; font-family:Arial, Helvetica, sans-serif;margin:10px 0px 0px 0px\">" + strs[1] + "</span></td></tr>"; result += "<tr><td style=\"padding:0px;margin:0px;text-align: left;line-height: 10px;border:none;border-width:0px;\"><span style=\"vertical-align:sub; color:red; font-size:9px; font-family:Arial, Helvetica, sans-serif;margin:10px 0px 0px 0px\">" + strs[2] + "</span></td></tr></table>"; } return result; }
以上代码主要是为了获取3个值, strs[0]=759 strs[1]=+0.6 strs[0]=-0.4 这样用来显示上下
??
??