文化变化时的动态字体大小(语言)

时间:2017-05-03 02:42:03

标签: c# html css fonts

拥有一个mvc Web应用程序,其中css在样式表中编码,将在视图中使用。

有没有办法实现以下场景:

  

当语言文化从英语变为其他时   语言,某些类字体大小的CSS将增加3px,但是当   语言文化从其他语言回到英语,字体大小   将减少3px到原始大小。

到目前为止,我一直在网上进行研究,但无法通过阅读C#的font size来更改css样式表中的CurrentUICulture(或者从cookie中读取)

1 个答案:

答案 0 :(得分:0)

试用此代码

$(function() {
  $(document).on("click","div.selectLang select",function(){
  	var curr=$("div.selectLang select").val();
    var arr=[".left",".left>p"];//list of elements to change fontsize
    if(curr=="English"){
	   for(var i=0;i<=arr.length;i++){
          var fontSize = parseInt($(arr[i]).css("font-size"));
    	  fontSize = fontSize - 3 + "px";
    	  $(arr[i]).css({'font-size':fontSize});
       }
    } else if(curr=="Spanish"){
		for(var i=0;i<=arr.length;i++){
          var fontSize = parseInt($(arr[i]).css("font-size"));
    	  fontSize = fontSize + 3 + "px";
    	  $(arr[i]).css({'font-size':fontSize});
       }
    }
  });
});
.left {
    font-size: 16px;
}
.left>p {
    font-size: 20px;
}
.right {
    font-size: 16px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="selectLang">
    <select>
    <option value="English" selected>English</option>
    <option value="Spanish">Spanish</option>
  </select>
  </div>

  <div class="left">
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
  <p>
  Where does it come from?
  </p>
  </div>
  <div class="right">
  It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look lik
  </div>