如何根据浏览器设置div的位置? [英] How to set div's position according to browser?
本文介绍了如何根据浏览器设置div的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有主要的div,因为我有背景颜色。
比我有其他div有图像(以png格式),在这个div我有多个div。所以从多个div我发布1 div。
1)当我使用这个代码为div,它在chrome,safari工作正常,即在Firefox中不起作用。:
I have main div , in that i have background color .
than i have other div which have image (in png form ), in this div i have multiple divs . so from multiple divs i posted 1 div.
1) when I have used this code for div , its works fine in chrome , safari , ie and not works in firefox.:
<div style="position: absolute; top:52.5em; left:10.1em;">
<asp:Label ID="lbl1" runat="server" CssClass="background fontStyle"></asp:Label>
<asp:Label ID="lbl2" runat="server" CssClass="background fontStyle"></asp:Label>
</div>
2)当我使用此代码时,它仅适用于firefox,以及其他浏览器中的标签被他们的位置打扰了。
2) when i used this code , it works only in firefox , and in other browser lables are got disturbed from their position.
<div style="position: relative; top:30.8em; left:10em;">
<asp:Label ID="lbl1" runat="server" CssClass="background fontStyle"></asp:Label>
<asp:Label ID="lbl2" runat="server" CssClass="background fontStyle"></asp:Label>
</div>
推荐答案
我为你添加了整个示例文件html代码可以测试: -
I have added the entire sample file html code for you which you can test :-
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style type="text/css">
.class1 {
width:200px;
height:200px;
background-color:black;
}
.class2 {
width:300px;
height:300px;
background-color:red;
}
</style>
<title></title>
<!-- This jQuery file is at root of my project and referenced here to use the jQuery script. -->
<script src="jquery-2.0.3.js"></script>
<script type="text/javascript">
( function (){
( #btnTest)。toggle(function (){
("#btnTest").toggle(function () {
这篇关于如何根据浏览器设置div的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文