我在包装 div 中有两个并排的 div。它们完美贴合并正确显示。但是,当我尝试向左侧 div 的左侧添加填充时,它不仅将该 div 的内容移至右侧,而且实际上还将右侧 div 的内容移至右侧!如果我添加任何超过 20px 的填充,它实际上会将右手 div 移动到下一行!这到底怎么可能?下面发布 CSS 和 HTML。包装 div 是“hwrapper”。左侧 div 是“rbox”,右侧 div 是“card”。正如我所说,在“rbox”的左侧添加填充也会将“card”的内容移动到右侧。我怎样才能解决这个问题?
#header {
height:800px;
width: 100%;
margin-top: 0px;
background:url(/assets/header-tail.gif) 0 0 repeat-x #f7f7f7;
}
#hwrapper {
width: 1000px;
height: 600px;
margin: 0 auto;
text-align: center;
}
#header .logo {
padding: 3px;
text-align: center;
}
#rbox {
background:url(/assets/hredbox.png) 0 0 no-repeat;
height: 420px;
width: 274px;
float: left;
text-align: left;
padding-top: 10px;
}
#card {
margin-left: auto;
height: 420px;
width: …Run Code Online (Sandbox Code Playgroud) 我有三个嵌套的 DIV 元素,如下所示:
<div id="outer">
<div id="innerA">
<div id="innerB">
This<br/>is<br/>a<br/>multiline<br/>testcase.<br/>
This<br/>is<br/>a<br/>multiline<br/>testcase.<br/>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
#innerA的高度100%使其与 一样大#outer。#innerB的高度保持不变,auto因此它的高度与其内容一样高。现在,当我设置#innerB为margin-top: 10px例如时,我预计#innerB将获得相对于 的余量#innerA。相反,会发生的情况是,#innerA获得与 相关的余量#outer。
这怎么可能?看来这与box-sizing至少它无法通过这种方式修复无关。
这是 CSS:
#outer {
width: 500px;
height: 300px;
background: yellow;
overflow: auto;
}
#innerA {
width: 100%;
height: 100%;
background: green;
}
#innerB {
margin-top: 10px;
background: blue;
}
Run Code Online (Sandbox Code Playgroud)
和小提琴:
(在这里,我希望绿色 DIV 适合黄色 DIV,并且在蓝色 DIV 上方可见绿色 …
我有一个关于 Android 工具栏的问题。通常,工具栏从左到右填充整个空间,并且顶部没有边距。
我的看起来像一块瓷砖,到处都有边距。Android Studio 渲染得很好,但当我在 Galaxy Tab 4 上运行它时,它看起来像一个图块。
截屏
活动:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_newsreader);
// create the toolbar
toolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Run Code Online (Sandbox Code Playgroud)
应用程序栏.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbarxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary"
app:popupTheme="@style/CustomToolbarPopup"
app:theme="@style/CustomToolbarTheme"
app:navigationIcon="@drawable/ic_home_white_16dp">
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
样式.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/primary</item>
<item name="android:textColorPrimary">@color/primary_text</item>
<item name="android:textColorSecondary">@color/secondary_text</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">@android:color/black</item>
</style>
<!-- -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
<!----> …Run Code Online (Sandbox Code Playgroud) <RelativeLayout>\n\n ...\n\n <ImageView\n android:id="@+id/imageView1"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_alignParentLeft="true"\n android:layout_marginLeft="10dp"\n android:layout_marginTop=\xe2\x80\x9d11dp\xe2\x80\x9d\n android:background=\xe2\x80\x9d@drawable/image\xe2\x80\x9d />\n\n</RelativeLayout>\nRun Code Online (Sandbox Code Playgroud)\n\n然后我需要以编程方式设置边距:
\n\nImageView imageView = (ImageView) findViewRoot(R.id.imageView1);\nRelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams();\nparams.width = 100;\nparams.height = 100;\nparams.setMargins(0,0,0,0); //NOT WORK\nimageView.setLayoutParams(params);\nRun Code Online (Sandbox Code Playgroud)\n\nImageView仍然有marginLeft 10和marginTop 11;
\n\n怎么了?
\n我有一些图像想要使用负边距进行堆叠。然而,由于堆叠没有明确定义边界的图像可能会在视觉上造成混乱,因此我认为应该在它们周围添加边框。奇怪的是,即使图像正确堆叠,它们的边框最终会位于前一个元素的下方。
为什么这是我得到的行为,有没有办法让边框以其直观的水平出现?
#second {
margin-top: -50px;
margin-left: 20px;
}
img {
border: 5px ridge green;
display: block;
}Run Code Online (Sandbox Code Playgroud)
<div><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/RCA_Indian_Head_test_pattern.JPG/312px-RCA_Indian_Head_test_pattern.JPG" height="100" width="auto"><img id="second" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/RCA_Indian_Head_test_pattern.JPG/312px-RCA_Indian_Head_test_pattern.JPG" height="100" width="auto"></div>Run Code Online (Sandbox Code Playgroud)
我已经寻找了许多解决方案,并且目前正在重做我拥有的网站的代码,因为我将所有 CSS 单独布局在每个 HTML 页面上。最终我有太多页面需要处理,我决定制作一个样式表来清理所有内容,但我的一切都一团糟。缩进、注释等...
目前,我正在网站上的导航栏上工作,但由于某种我无法弄清楚的原因(我已经尝试了很多东西),导航栏恰好位于中间,在中间留下了少量空白栏的顶部、左侧和右侧。这是 HTML:
ul { /* unordered list properties */
list-style-type: none; /*takes out bullet points */
margin: 0; /* scaling */
padding: 0; /* scaling */
overflow: hidden; /* clipping rules: https://www.w3schools.com/cssref/pr_pos_overflow.asp */
background-color: #0c1f2e; /* colour */
}
li { /* list item properties */
float: left; /* move item to the left */
font-size: 14px; /* set the font size to 14 pixels */
}
li a { /* vertical style */
display: …Run Code Online (Sandbox Code Playgroud)我想要 Matplotlib 中的一个函数类似于Matlab 的“scatterhist”函数,它采用“x”和“y”轴的连续值,加上一个分类变量作为输入;并生成一个散点图,其中包含边际 KDE 图和两个或多个不同颜色的分类变量作为输出:
我在 Matplotlib 中
找到了带有边缘直方图的散点图示例,在 Seaborn jointplot 中找到了边缘直方图,在 Matplotlib 中找到了重叠直方图,在 Matplotib 中找到了边缘 KDE 图;但我还没有找到任何将散点图与边际 KDE 图结合起来并用颜色编码来指示不同类别的示例。
如果可能的话,我想要一个使用“vanilla”Matplotlib而不使用Seaborn的解决方案,因为这将避免依赖性并允许使用标准Matplotlib命令完全控制和自定义绘图外观。
我打算尝试根据上面的例子写一些东西;但在此之前,我想检查一下类似的功能是否已经可用,如果没有,那么将不胜感激有关最佳使用方法的任何指导。
我的应用程序中有一个全屏活动。我希望我的页面标题位于状态栏下方。如何测量全屏活动中状态栏的高度?
我对此进行了研究并尝试了它们。其中之一是this,它使用了 xml 中的一个属性,但在我的情况下不起作用。另一种是第二种解决方案
val rectangle = Rect()
window.decorView.getWindowVisibleDisplayFrame(rectangle)
val statusBarHeight = rectangle.top
Run Code Online (Sandbox Code Playgroud)
statusBarHeight是 0,因为它可能是全屏活动。有什么帮助可以将我的一些元素(例如标题)放置在状态栏工作人员下方吗?
请一位有才华的人能帮助我完成这个页面布局,或者告诉我是否有可能?
尝试嵌入一些闪存内容,这些内容随浏览器调整大小,但左边有400px的边距,底部有200px的边距.设法获得了左边的边距,但无法让底部边距留在浏览器中.
我的div看起来像这样:
<div style="height:100%;margin-left:400px;">
<div id="flashcontent"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
swf与swfobject动态嵌入到flashcontent div中,对此有任何帮助将不胜感激.
麦克风
你知道为什么我不能从我的<li>元素中删除边距吗?浏览器总是为我的列表添加特定的边距,即使我将代码写入特定的边距.这是CSS和HTML代码:
#NavLeftList {
height: 57 % ;
width: 15 % ;
position: absolute;
top: 23 % ;
border-style: none;
background: url(images / heaven.jpg);
margin: 0px
}
#NavLeftList ul {
margin-left: 11 % ;
}
#NavLeftList ul li {
text-align: center;
width: 170px;
list-style-type: none;
text-decoration: none;
margin: 10px 0px 0px 0px;
padding: 1px;
}
#NavLeftList li a {
height: 35px;
padding: 10px 0px 0px 0px;
text-decoration: none;
color: #fff;
background: url(images / tabright.gif);
display: block
}
#NavLeftList li …Run Code Online (Sandbox Code Playgroud) margin ×10
css ×6
html ×4
android ×3
padding ×3
height ×1
histogram ×1
html-lists ×1
kde-plasma ×1
matplotlib ×1
navigation ×1
scatter-plot ×1
statusbar ×1
toolbar ×1