zoukankan      html  css  js  c++  java
  • 根据不同的多语言环境来切换不同的页面样式的具体示例

    //页面展示文字有时显示不同的语言时,相同的样式可能会有不同的展现,比如中文显示正常,英文因为比较长导致显示错位等情况,这时候就可以根据语言环境来动态的切换样式,实现如下:

    <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> body .t { font-size: 16px; color: red; } body[lang="en-us"] .t { font-size: 20px; font-weight: bold; color: #000000; } </style> <script type="text/javascript"> window.onload = function () { document.getElementById('a').onchange = function () { document.getElementsByTagName('body')[0].setAttribute('lang', this.value); } } </script> </head> <body lang="en-us"> <select id="a"> <option value="en-us">英文</option> <option value="zh-cn">中文</option> </select> <div class="t"> ABC </div> </body> </html> 也可以整个HTML代码根据下面的lang="en"属性进行判断,再给不同的样式 <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body></body> </html> 样式如: /*英文语言环境时的专属样式----begin*/ html:lang(en-US) .stepDesc { 110px; } html:lang(en-US) .swMain ul.anchor li a .stepNumber { position: relative; float: left; 20px; text-align: center; padding: 0 2px 2px; font: bold 26px Verdana, Arial, Helvetica, sans-serif; } html:lang(en-US) .swMain ul.anchor li a .stepDesc { font-size: 14px; padding: 0; padding-top: 2px; line-height: 16px; font-weight: normal; } /*英文语言环境时的专属样式----end*/
  • 相关阅读:
    sqlhelper使用指南
    大三学长带我学习JAVA。作业1. 第1讲.Java.SE入门、JDK的下载与安装、第一个Java程序、Java程序的编译与执行 大三学长带我学习JAVA。作业1.
    pku1201 Intervals
    hdu 1364 king
    pku 3268 Silver Cow Party
    pku 3169 Layout
    hdu 2680 Choose the best route
    hdu 2983
    pku 1716 Integer Intervals
    pku 2387 Til the Cows Come Home
  • 原文地址:https://www.cnblogs.com/itjeff/p/11138475.html
Copyright © 2011-2022 走看看