GVKun编程网logo

IE CSS错误:background-color:transparent的行为不同于background-color :(任何其他颜色)

8

对于IECSS错误:background-color:transparent的行为不同于background-color:感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍任何其他颜色,并为您提供

对于IE CSS错误:background-color:transparent的行为不同于background-color :感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍任何其他颜色,并为您提供关于的background-image和background-color层次问题_html/css_WEB-ITnose、android RecyclerView BackgroundColor、android setBackgroundResource setBackgroundColor setBackgroundResource区别、android – RecyclerView BackgroundColor的有用信息。

本文目录一览:

IE CSS错误:background-color:transparent的行为不同于background-color :(任何其他颜色)

IE CSS错误:background-color:transparent的行为不同于background-color :(任何其他颜色)

我一直在努力找出为什么这种转换没有像IE8那样运行。

转到此处:IE8中的,您将看到翻转仅适用于缩略图的下半部分。

顺便说一句,这不是由<a>标签激活的,而是由的激活:hover<div>

我不知道为什么它只能在div的下半部分(在图像下方)工作,而不在图像上工作(图像未进行z索引,所以这不是问题)

只要将background-color透明层以外的任何其他内容更改为100%,它就会起作用。所以这真让我大吃一惊……为什么只有当我将bg-
color设置为透明时,才是下半部而不是上半部?要爱Internet Explorer。

这在所有其他浏览器上均应正常工作(整个方块都可以用作过渡)

这是CSS:

.cat_rollout {    position: absolute;    float:left;    top:0;    left:0;    min-height:274px;    min-width:274px;    font-size: 0;    background-color: transparent;}.cat_rollout:hover {    background-image: url(images/rollover.png);    min-width:254px;    min-height:242px;    padding-left: 20px;    color: white;    font-size: 21px;    font-weight: normal;    line-height: 24px;    padding-top: 34px;}

答案1

小编典典

尝试伪造背景图像或将其设置为blank.gif 而不是 使其透明。

background:url(blank.gif);

<body>的background-image和background-color层次问题_html/css_WEB-ITnose

的background-image和background-color层次问题_html/css_WEB-ITnose

body { background-image:url(pics/bg.png); background-repeat:repeat; background-color:#069;}
登录后复制

设置成这样,但背景颜色总是会覆盖在背景图片上,怎么能让背景图片在背景颜色上从而不受背景颜色影响?

回复讨论(解决方案)

你路径写错了呗。

背景图片,会覆盖背景色的,看下路径,在调试工具里,看下这个图片,是不是成功加载过来了。

图片路径不对吧

你路径写错了呗。

背景图片,会覆盖背景色的,看下路径,在调试工具里,看下这个图片,是不是成功加载过来了。
很确定背景图片已经加载了,和背景颜色叠加在一起出现了奇特的效果。

你确定加载了,那就看下,body下的第一个子元素,是不是占据整个body的,是不是你在这个子元素上面,设置了颜色。

再仔细检查下你的代码,颜色覆盖背景图片。还真是没有见过。

你把body的颜色去掉,看看会不会出背景色,就能确定,是不是背景图片被颜色覆盖了。

background:#069 url(pics/bg.png) no-repeat center center;

你的背景图片是png格式的,不要告诉我,撒是png这个你不懂

你的背景图片是png格式的,不要告诉我,撒是png这个你不懂
好吧,是图片半透明了

android RecyclerView BackgroundColor

android RecyclerView BackgroundColor

当我使用RecyclerView在我的应用程序中显示列表数据时,RecyclerView的backgroundcolor始终为白色:

screenshot

我在xml文件和代码中设置backgroundcolor,但它不起作用:

//activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    android:background="@color/colorPrimary">
    <!--<include layout="@layout/content_main" />-->
    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></FrameLayout>
</LinearLayout>

//fragment_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorAccent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorAccent"
        android:padding="5dp" />
</RelativeLayout>

//item_layout.xml
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    card_view:cardBackgroundColor="@color/yellow"
    card_view:cardCornerRadius="1dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="5dp">

        <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="5dip"
            android:layout_marginTop="5dip"
            android:gravity="center"
            android:textColor="@color/text_white"
            android:textSize="@dimen/list_item_text_size" />

        <ImageView
            android:id="@+id/pic"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/name"
            android:scaleType="centerCrop" />
    </RelativeLayout>

</android.support.v7.widget.CardView>


    //gradle file
    compileSdkVersion 23
    buildToolsversion "23.0.2"

    defaultConfig {
        applicationId "com.union.fmdouban"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

解决方法:

我已经实现了以下代码,这显示了卡片视图和背景color

enter image description here

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

    <android.support.v7.widget.RecyclerView
        android:id="@+id/appointment_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFF00"
        android:scrollIndicators="none" />
</RelativeLayout>

//你的适配器的布局

  <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#000"
        android:padding="5dp">

        <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="5dip"
            android:layout_marginTop="5dip"
            android:gravity="center"
            android:text="dfgjkdfh"
            android:textColor="#ffffff" />

        <ImageView
            android:id="@+id/pic"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/name"
            android:scaleType="centerCrop" />
    </RelativeLayout>

</android.support.v7.widget.CardView>

我从适配器的XML中删除了主要的相对布局试试这个让我知道

//我的Gradle看起来像这样

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsversion "23.0.2"

    defaultConfig {
        applicationId "betasoft.com.tryso"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile filetree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.android.support:design:23.1.1' }

android setBackgroundResource setBackgroundColor setBackgroundResource区别

android setBackgroundResource setBackgroundColor setBackgroundResource区别

 总结一下:setBackgroundResource(R.color.XXX)改变的颜色是最下层的颜色,当改变完颜色以后,因为我头部布局在xml文件中默认颜色是white,所以又给white遮盖掉了。

       xml 文件中布局默认的颜色呢,可以理解为显示在中层。当我用Resource这个方法,把颜色改变过来以后,它因为在最下层,所以直接被中层的给刷掉了,因此颜色又变了回去。

       而setBackgroundColor(context.getResouce().getColor(R.color.XXX))呢,可以理解为改变的是最上层的颜色,不管我xml布局中的颜色是什么色,我在你布局颜色上层又给刷了回去。所以就显色了。

android – RecyclerView BackgroundColor

android – RecyclerView BackgroundColor

我使用RecyclerView显示一些文本数据.我在其中选择了不同的卡片.

我想改变所选卡片的外观.

public void toggleSelection(int pos)
    {
        RecyclerView.ViewHolder viewHolder = recView.findViewHolderForPosition(pos);
        if (selectedItems.get(pos, false)) {
            selectedItems.delete(pos);
            viewHolder.itemView.setBackgroundColor(Color.WHITE);
        }
        else {
            selectedItems.put(pos, true);
            viewHolder.itemView.setBackgroundColor(Color.GREEN);
        }
        notifyItemChanged(pos);
    }

如果我像这样使用我的代码它是有效的.我的onClick事件触发此代码,我的卡背景颜色变为绿色.

所以这是我的问题:向下滚动显示其他卡片在相同的相对位置(但在列表中更下方),即使没有被选中,也会使用相同的背景颜色;选择第一张卡并向下滚动到第八张卡是顶部可见卡的位置,显示第八张卡突出显示.

解决方法:

您需要在onBindViewHolder()方法中显式设置颜色.回收站视图的名称建议回收视图,因此第0项将被回收为您案例中的第8项.它们使用使用onCreateViewHolder()方法创建的相同视图持有者.每当其中任何一个进入视图时,都会调用onBindViewHolder()方法.
我建议你在数据模型中创建一个额外的布尔字段,告诉你是否突出显示了视图.你应该在toggleSelection()中切换它.
然后在onBindViewHolder()中检查该字段的值并相应地设置颜色.

今天关于IE CSS错误:background-color:transparent的行为不同于background-color :任何其他颜色的讲解已经结束,谢谢您的阅读,如果想了解更多关于的background-image和background-color层次问题_html/css_WEB-ITnose、android RecyclerView BackgroundColor、android setBackgroundResource setBackgroundColor setBackgroundResource区别、android – RecyclerView BackgroundColor的相关知识,请在本站搜索。

本文标签: