- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 w3-css 和 bog-standard css。
我有一个单词的png:INSPIRE,它的字体是透明的。字母后面是彩色矩形。彩色矩形前面是白色矩形,给人以 INSPIRE 字母被填满的印象,具体取决于矩形达到的高度。示例 ( under the link) 将白色矩形设置为 50% 高度。在最初,这些高度是由从数据库中提取的数字决定的,而不是按照脚本中的方式设置。
INSPIRE 的填充是这样发生的:
有一个名为 w3-third 的 'w3 div',其中有另一个名为 w3-card 的 div,其中是一个普通的 div - 在标题中设置样式- 称为 back,其中包含每个字母 block 的 div,最后是 INSPIRE png 的 div。我使用 z 值,所以 png 位于顶部。
我这辈子都无法让 INSPIRE 图像位于 w3-card div 的中央。
如果我可以挥舞魔杖,那么我会“居中”#back div。我试过设置宽度...
#back {
position: absolute;
width: 294px;
margin: 0 auto;
z-index: 0;
}
但这没有什么区别。
拜托,在我脑袋爆炸之前请帮忙......
下面是链接的完整页面代码:
<html>
<head>
<title>
INSPIRE
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-black.css">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css">
<style>
#back {
position: absolute;
width: 294px;
margin: 0 auto;
z-index: 0;
}
#behindI {
position: absolute;
left: 0px;
z-index: 1;
}
#behindN {
position: absolute;
left: 33px;
z-index: 1;
}
#behindS {
position: absolute;
left: 80px;
z-index: 1;
}
#behindP {
position: absolute;
left: 113px;
z-index: 1;
}
#behindII {
position: absolute;
left: 160px;
z-index: 1;
}
#behindR {
position: absolute;
left: 200px;
z-index: 1;
}
#behindE {
position: absolute;
left: 247px;
z-index: 1;
}
#front {
position: absolute;
z-index: 3;
}
#myCanvasI {
z-index: 2;
}
</style>
<script>
var i = 0.5;
var n = 0.5;
var s = 0.5;
var p = 0.5;
var ii = 0.5;
var r = 0.5;
var e = 0.5;
</script>
</head>
<body>
<div class="w3-third">
<div class="w3-card-2 w3-padding-top w3-black w3-center" style="min-height:460px">
<h3>Characteristics of Learning</h3><br>
<p>How are you doing in each area? </p>
<p>Are you the full INSPIRE? </p>
<div id="back">
<div id="front">
<img src="images/fullinspire33.png" />
</div>
<div id="behindI">
<canvas id="myCanvasI" width="33" height="33">
<script>
var z=document.getElementById("myCanvasI");
var ctx=z.getContext("2d");
ctx.fillStyle="red";
ctx.fillRect(0,0,33,33);
ctx.stroke();
ctx.fillStyle="white";
ctx.fillRect(0,0,33,33*i);
ctx.stroke();
</script>
</canvas></div>
<div id="behindN">
<canvas id="myCanvasN" width="47" height="33">
<script>
var y=document.getElementById("myCanvasN");
var ctx=y.getContext("2d");
ctx.fillStyle="orange";
ctx.fillRect(0,0,47,33);
ctx.stroke();
ctx.fillStyle="white";
ctx.fillRect(0,0,47,33*n);
ctx.stroke();
</script>
</canvas> </div>
<div id="behindS">
<canvas id="myCanvasS" width="33" height="33">
<script>
var x=document.getElementById("myCanvasS");
var ctx=x.getContext("2d");
ctx.fillStyle="yellow";
ctx.fillRect(0,0,33,33);
ctx.stroke();
ctx.fillStyle="white";
ctx.fillRect(0,0,100,33*s);
ctx.stroke();
</script></canvas></div>
<div id="behindP">
<canvas id="myCanvasP" width="47" height="33">
<script>
var w=document.getElementById("myCanvasP");
var ctx=w.getContext("2d");
ctx.fillStyle="green";
ctx.fillRect(0,0,47,33);
ctx.stroke();
ctx.fillStyle="white";
ctx.fillRect(0,0,47,33*p);
ctx.stroke();
</script>
</canvas>
</div>
<div id="behindII">
<canvas id="myCanvasII" width="40" height="33">
<script>
var v=document.getElementById("myCanvasII");
var ctx=v.getContext("2d");
ctx.fillStyle="blue";
ctx.fillRect(0,0,40,33);
ctx.stroke();
ctx.fillStyle="white";
ctx.fillRect(0,0,40,33*ii);
ctx.stroke();
</script>
</canvas>
</div>
<div id="behindR">
<canvas id="myCanvasR" width="47" height="33">
<script>
var u=document.getElementById("myCanvasR");
var ctx=u.getContext("2d");
ctx.fillStyle="indigo";
ctx.fillRect(0,0,47,33);
ctx.stroke();
ctx.fillStyle="white";
ctx.fillRect(0,0,47,33*r);
ctx.stroke();
</script>
</canvas>
</div>
<div id="behindE">
<canvas id="myCanvasE" width="47" height="33">
<script>
var t=document.getElementById("myCanvasE");
var ctx=t.getContext("2d");
ctx.fillStyle="violet";
ctx.fillRect(0,0,47,33);
ctx.stroke();
ctx.fillStyle="white";
ctx.fillRect(0,0,47,33*e);
ctx.stroke();
</script>
</canvas>
</div>
</div>
</div>
</div>
</body>
</html>
最佳答案
只需添加另一个 div,像这样用 id black 包裹 div
<div style="
display: inline-block;
width: 295;
height: 35px;
margin: auto;
">
<div id="back"> you stuff in this div </div>
</div>
以防万一你想将 id 为黑色的 div 保持为 position:absolute;
关于javascript - 如何将一个 <div> 置于其他几个 <div> 的中心(混合使用 w3.css 和 css),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40303928/
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: How to align a to the middle of the page 这是一个简单的问题,应该有一个简
我想知道如何在屏幕中央的ListView中生成2个itens。 class _CategoriesState extends State { List categories = ["Anterio
我需要修复 UICollectionView 的一个小问题,当在 6s 设备尺寸上时,我得到如下布局: 但是,我想知道将它们居中以使其成为两条线的最佳方法是什么,或者我应该将它们缩小一点以便可以放置其
我尝试在 UIImageView 中居中 CAShapeLayer 但没有成功,我找到了解决方案,将其(CAShapeLayer)添加到 UIVIew,然后将 UIVIew 添加到 ImageView
一直在从线性布局和相对布局切换,因为我想实现图像的居中。 显示图片:
* { margin:0; padding:0; } /** General Style Info **/ body { background: #003d4c; co
我目前正在尝试修改我在 Wordpress 上的 Royal Slider 插件 (http://dimsemenov.com/plugins/royal-slider/) 我的目标是将所有标题的文本
我已经坚持了一段时间,因此简化了我的要求。当您单击标记时,信息窗口将打开,当用户缩放时,我希望该标记位于 map 的中心。这不起作用,但我认为它很接近: function bindInfoWindow
/* Linked Styles */ body { padding: 0 !important;
这个问题在这里已经有了答案: How do I center floated elements? (12 个答案) 关闭 7 年前。
这个问题在这里已经有了答案: Is there an equivalent to background-size: cover and contain for image elements? (1
我试图让我的页眉停留在页面的中间,不管我在什么窗口大小。 我试过使用 Bootstrap。 StackOverflow 还有这个 CSS。 .section-t
我有一个 1600 像素宽的页面。主要区域虽然只有 900 像素宽。我有一个导航应该固定在页面的中心(它是)。我的问题是当我打开页面时,页面固定在左侧而不是在打开时居中。当用户访问该网站时,我需要做什
我正在尝试找到 View 的中心。对于非旋转 View ,该值是正确的,但对于旋转 View ,它不正确,因为中心 (0,0) 正在旋转。在缩放的情况下,即使缩放后宽度和高度也保持不变 我正在使用以下
预期效果是将 Kartennummer 和 Passwort 集中。 这怎么可能? 我为此使用了一个自定义类: import 'package:flutter/material.dart'; impo
我管理着许多 Maven 项目。他们中的大多数部署到我们的内部 maven 存储库。现在我想开始向 Maven Central 发布一个项目。到目前为止,我有一个父 POM,它指定了我们内部存储库的
我试图锚定两个进展,但我看不到获得预期结果的方法。 我希望左边的进度条固定在左边,右边的条固定在中心固定(如下图所示) (下图显示调整大小的表格) 我尝试将控件放在具有各种 anchor 的停靠面板上
我正在玩 Angular 模态 ui 对话框。我想知道有什么方法可以让它居中?我发现了一个类似的问题: Twitter Bootstrap - Center Modal Dialog 但无法使其工作,
是否可以将值标签放置在条形上,使它们位于条形的中心? 如果我设置条形 align: "center",则条形上的标签将关闭且不居中。 $(function() { var d
http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-s
我是一名优秀的程序员,十分优秀!