gpt4 book ai didi

c# - 文化(语言)发生变化时的动态字体大小

转载 作者:行者123 更新时间:2023-11-28 03:50:16 26 4
gpt4 key购买 nike

有一个 mvc web 应用程序,CSS 在样式表中编码,将在 View 中使用。

有什么办法可以实现下面的场景:

When there is a change of language culture from english to other language, the css for certain class font size will increase by 3px, but when the language culture from other language back to english, the font size will decrease back by 3px to the original size.

到目前为止一直在网上研究,但找不到通过阅读 C# 的 CurrentUICulture(或者阅读来自 cookie)

最佳答案

试试这个代码

$(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>

关于c# - 文化(语言)发生变化时的动态字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43750193/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com