标签: margin

Div使用z-index除以Div

我的HTML中有以下div:

<div class="main">
<div class="bgimage"></div>
<div class="content">Text</div>
Run Code Online (Sandbox Code Playgroud)

它直接在我体内.

使用以下CSS:

body {
    margin: 0;
    padding: 20px 0;
}
.content {
    filter: alpha(opacity=50);
    -moz-opacity: 0.5;
    opacity: 0.5;
}
.content {
    position: relative;
    z-index: 1;
    border: #000 thin solid;
    width: 960px;
    margin-left: auto;
    margin-right: auto;
    background-color: #000;
}
.bgimage {
    position: absolute;
    z-index: -1;
    width: 1024px;
    height: 768px;
    margin-left: auto;
    margin-right: auto;
    background-image: url(bg1.jpg);
}
Run Code Online (Sandbox Code Playgroud)

基本上,我有一个显示背景图像的Div,我将在透明度上有另一个Div.这个当前代码有效,但我的问题是当我试图从顶部取下内容div时.

当我添加margin-top:100px时,例如,也会降低图像.如果它不在同一个z-index上,我认为它不会碰它?为什么添加边距也会迫使bgimage div下降?

我也尝试用内容类来制作div的绝对位置和zindex,但是这不会居中.我该怎么解决这个问题?

html css margin z-index

9
推荐指数
2
解决办法
9万
查看次数

有没有办法在CSS中添加和减去值?

我有一个div,我以负边距定位,但我希望它一直延伸到它的容器div的底部,所以我可以使用一个不仅随机结束的边框.如果你看一下http://kineticaid.com/k/home.php,你会明白我的意思.我不能仅以像素为单位扩展其高度,因为容器div的高度随页面动态变化.我想做的是这样的:

#rightcol {
float: right;
width: 225px;

height: 100% + 250px;

margin: -325px -25px 0 0;
}
Run Code Online (Sandbox Code Playgroud)

基本上我问你是否可以在CSS中添加和减去.谢谢!

css height margin

9
推荐指数
2
解决办法
1万
查看次数

使用wrap_content时为什么忽略layout_marginBottom?

我有以下布局文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#FF0000" >

<RelativeLayout
    android:id="@+id/usericon_img"
    android:layout_width="73.3334dp"
    android:layout_height="70.6667dp"
    android:layout_marginBottom="2.6667dp"
    android:layout_marginLeft="3.3334dp"
    android:layout_marginTop="2.6667dp"
    android:background="#FFFFFF" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

在模拟器上(我在真实设备上测试它看起来一样)布局看起来像这样:在此输入图像描述

我的问题是:为什么我在白色布局下没有红色边缘?我知道如果我将外部布局更改为:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="76dp"
android:background="#FF0000" >
Run Code Online (Sandbox Code Playgroud)

我会得到我想要的,但为什么wrap_content不能正常工作?

android margin relativelayout

9
推荐指数
1
解决办法
5686
查看次数

Wkhtmltopdf边距(顶部和底部)

我在a:Linux 3.2.0-24-generic#38-Ubuntu x86_64 GNU/Linux上使用wkhtmltopdf 0.10.0 rc2

我无法使用margin-top或创建PDF margin-bottom(没有错误)

我正在使用以下命令:

wkhtmotopdf -T 50 -B 50 http://google.com ./test.pdf
wkhtmotopdf --margin-top 50 --margin-bottom 50 page.html ./test.pdf
Run Code Online (Sandbox Code Playgroud)

当我尝试这个:

wkhtmotopdf -L 50 -R 50 -T 50 -B 50 page.html ./test.pdf
Run Code Online (Sandbox Code Playgroud)

左边和右边的边距完美(仍然没有边缘顶部或边缘底部).我转换的URL或页面无关紧要.

编辑:

看起来这是一个错误.对于仍然需要一些利润率/利润率最低的人.尝试使用header-html/footer-html功能:

刚刚意识到剪切问题是通过添加header-spacing和footer-spacing参数来修复的:

wkhtmotopdf -L 50 -R 50 -T 50 -B 50 http://google.com --header-html blank.html --header-spacing 5 --footer-html blank.html --footer-spacing 5 ./test.pdf

linux pdf ubuntu margin wkhtmltopdf

9
推荐指数
0
解决办法
8991
查看次数

边距底部不会在<a>标签下创建空间

在我的HTML表单中,我有一个链接<a href='...'>...</a>后跟一个标签<label ...>...</label>.我为此链接设置了下限,如下所示:

form a {
    margin-bottom: 10px;
}
Run Code Online (Sandbox Code Playgroud)

当我使用谷歌Chrome控制台检查元素时,a标签确实有margin-bottom10px.但标签正好在它下面没有空间.我怎样才能在那里产生一些空间?

css margin

9
推荐指数
2
解决办法
4260
查看次数

电邮客户支持负保证金价值?

请看下面的截图

在此输入图像描述

我想把镜头定位在顶部区域position.电子邮件客户端不支持这个值.那么我能为那做什么margin-top呢?我用价值作为负值?希望你能帮助我..谢谢你

html css email-client position margin

9
推荐指数
2
解决办法
2万
查看次数

没有边距或填充 - 但div元素之间仍然是空格

这不是第一次让我感到困惑.

<div id="wrap">
<div class="content"></div>
<div class="content"></div>
<div class="content"></div>
<div class="content"></div>
</div>

#wrap {
width:400px;
height:200px;
background:red;
margin:0px 0px 0px 0px;
padding:0px 0px 0px 0px;
}

.content {
width:100px;
height:200px;
display:inline-block;
background:green;
margin:0px 0px 0px 0px;
padding:0px 0px 0px 0px;
}
Run Code Online (Sandbox Code Playgroud)

在JSFiddle上查看时,您可能会有更好的理解

JSFiddle示例

根据我的理解,四个div应该完全适合父div,但它们之间有一个空间 - 我不明白它的来源.

如果有人能为我解决这个问题会很棒.

html css positioning margin padding

9
推荐指数
2
解决办法
7114
查看次数

使用GridLayoutManager实现RecyclerView中的项目

我有一个使用GridLayoutManager实现的RecyclerView.

根据数据集中的项目数量,spanCount介于1-4之间.项目宽度根据spanCount而变化.如果spancount为4或更高,则spanCount保留为4.

如果我有5个项目,则剩下1个项目(1行中有4个项目,剩下1个项目),位于屏幕左侧,单独排成一行.我希望它集中在一起.

我已经尝试以编程方式设置左侧项目的边距,并将recyclerView和各个项目包装在LinearLayouts中,并将重力设置为居中,以及设置recyclerView的重力.

示例项XML:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="horizontal"

    >


    <RelativeLayout
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_gravity="center"
        android:id="@+id/relative"
        /> 

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

示例RecyclerView XML

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="horizontal"
            >
           <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            />

        </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议一个解决方案,或者给我一些工作材料.

提前致谢.

android margin centering gridlayoutmanager android-recyclerview

9
推荐指数
1
解决办法
7041
查看次数

ChartJS - 有什么方法可以删除饼图周围的空白区域?

饼形图

我正在处理左侧和右侧有不需要的间距的图表.我一直在尝试删除它,没有运气,我不知道现在还能做什么.我已经彻底阅读了文档,但似乎无法找到解决方案.这可能吗?如果需要更多信息,请告诉我,我会提供.

编辑:

<div>
<canvas id="chart-gender"></canvas>  
</div>


<script>
var gender_data = [10, 35];

var graph_gender_preset = {
    labels: ["Female", "Male"],
    datasets: [
        {
            data: gender_data,
            backgroundColor: ["#0fa0e3", "#ff3549"]
        }
    ]
};

var ctx3 = $("#chart-gender");

var chart_gender = new Chart(ctx3, {
type: 'doughnut',
data: graph_gender_preset,
options: {
        responsive: true,
        title: {
            display: false,
            position: "top",
            fontStyle: "bold",
            fontSize: 0,
            fullWidth: false,
            padding: 0
        },
        legend: {
            display: false,
            position: "top",
            fullWidth: false,
            labels: { display: false, usePointStyle: true, fontSize: 15, fontStyle: …
Run Code Online (Sandbox Code Playgroud)

javascript space margin chart.js

9
推荐指数
2
解决办法
4292
查看次数

在边缘弄乱的布局背景

我正在尝试为我的视频播放器制作一个微调吧

trimmer_bar.xml

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/thumbsBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="40dp"
        tools:background="@color/trimmerBarSelected">


        <ImageView
            android:id="@+id/leftThumb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription=""
            android:scaleType="fitStart"
            android:src="@drawable/ic_left_thumb" />


        <ImageView
            android:id="@+id/rightThumb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:contentDescription=""
            android:scaleType="fitEnd"
            android:src="@drawable/ic_right_thumb" />


    </RelativeLayout>
    <ImageView
        android:id="@+id/progressIndicator"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginStart="60dp"
        android:layout_marginTop="3dp"
        android:contentDescription=""
        android:scaleType="centerCrop"
        android:src="@android:drawable/btn_star_big_on" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

activity_video_viewer:

 <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="#a8c71c"
        tools:context=".activities.VideoTrimmerActivity">

        <com.tomatedigital.instagram.longstories.ui.TrimmerBar
            android:id="@+id/trimmerBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/trimmerBarSelected"
            />
    </FrameLayout>
Run Code Online (Sandbox Code Playgroud)

它的逻辑运作得很好:当用户触摸时,我检测到它是否在左拇指上的任何拇指和外壳上我调整了thumbBar的左边距,右边的情况我调整右边距...

由于两个imageview与边缘对齐,这种行为使它们移动......但实际上移动的是整个RelativeLayout

问题是甚至调整边距并移动图像视图,相对布局仍然显示边缘区域中的背景

忽略整个计算我使用以下方法设置边距:

this.thumbsBar= (RelativeLayout) findViewById(R.id.thumbsBar);
this.thumbsBarLayout = (LayoutParams) …
Run Code Online (Sandbox Code Playgroud)

android trim margin android-layout android-relativelayout

9
推荐指数
1
解决办法
146
查看次数