我练习中心没有宽度的div,并找到了适用于每个常见浏览器的解决方案.但是当我把这个解决方案变成真正的页面样式时,它在IE中不起作用.
在IE,Chrome和Firefox中完美运行的练习解决方案如下所示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Centerbox</title>
<link type="text/css" rel="stylesheet" href="centerbox.css" media="all" />
</head>
<body>
<div class="centerbox-outer">
<div class="centerbox-inner">
<p>Sample content that is not fixed width</p>
<p>Some more content</p>
<form>
<input type="text" name="sampleinput" />
<input type="submit" name="go" />
</form>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
centerbox.css
div.centerbox-outer{
text-align: center;
margin: 0 auto;
}
div.centerbox-inner{
text-align: justify;
background-color: gray;
display: inline-block;
}
Run Code Online (Sandbox Code Playgroud)
它不使用IE的页面在这里:[链接已删除]
有人有任何想法,我在那里缺少什么?
我只是想不出来.我在res/drawable/start_light.xml中有这个形状
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadius="20dp"
android:thickness="0dp"
android:useLevel="false">
<solid android:color="#FF0000" />
</shape>
Run Code Online (Sandbox Code Playgroud)
在res/values/styles.xml中我有:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="StartLight">
<item name="android:layout_height">50dp</item>
<item name="android:layout_width">50dp</item>
<item name="android:background">@drawable/start_light</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
在主要布局中我有:
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:gravity="center_vertical" android:layout_height="150dp">
<ImageView android:src="@drawable/start_light" android:id="@+id/light5" android:layout_width="50dp" android:layout_height="50dp"></ImageView>
<View style="@style/StartLight" android:id="@+id/light4"></View>
<View style="@style/StartLight" android:id="@+id/light3"></View>
<View style="@style/StartLight" android:id="@+id/light2"></View>
<View style="@style/StartLight" android:id="@+id/light1"></View>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
以太网方式,使用View或ImageView我在模拟器和设备上的布局中看不到任何红色圆圈.在xml图形设计师他们在那里.我在这里错过了什么?