2016-01-22 59 views
0

我有一个包含分组对象列表项的列表。 Like here in the Explored App,点击Samples。现在,所有这些项目都有一个填充1rem,由CSS与选择器.sapMLIB.sapMObjLItem给出。如何从对象列表项中删除填充?

现在我想减少顶部和底部填充到0.25rem,所以增加了一个 类对象和进口的自定义的CSS(经由manifest.json),所有所描述的in the Walkthrough。它不工作,因为正常的CSS覆盖我的自定义的。

另一个尝试是将类sapUiNoContentPadding添加到元素,但也是后面的css规则会被第一段中描述的规则覆盖。

我在做什么错?如何删除该填充而不重写渲染器?

MyView的:

<mvc:View 
    controllerName="sap.ui.xxxx.someapp.controller.MyList" 
    xmlns="sap.m" 
    xmlns:mvc="sap.ui.core.mvc"> 
    <StandardListItem title="Titel"/> 
    <List class="sapUiResponsiveMargin sapUiNoContentPadding" 
    width="auto" 
    items="{path : '//elementsSet', 
     sorter : { 
     path : 'attribute1}', 
     group : true 
     } 
    }"> 
    <items> 
     <ObjectListItem title="{= ${attribute1} === '' ? 'Enter Text Please' : ${attribute1}}" 
     icon="{= ${attribute1} === '' ? 'sap-icon://alert' : 'sap-icon://sys-enter'}" 
     number="{attribute4}" 
     numberUnit="$" 
     numberState="{= ${attribute4} > 10 ? 'Error' : 'Success' }" 
     type="Active" press="onItemPress" 
     markFlagged="true" markFavorite="true" 
     showMarkers="true" 
     class="sapUiNoContentPadding myownclassforpadding"> 
     <firstStatus> 
      <ObjectStatus 
      text="some text" /> 
     </firstStatus> 
     <attributes> 
     <ObjectAttribute text="{attribute1}" visible="false"/> 
     <ObjectAttribute text="{attribute2}"/> 
     <ObjectAttribute text="{attribute3}" visible="false"/> 
     <ObjectAttribute text="{attribute4}" visible="false"/> 
     </attributes> 
     </ObjectListItem> 
    </items> 
    </List> 
</mvc:View> 

我的CSS

.myownclassforpadding{ 
    padding: 0; 
    background-color: green; 
} 

回答

1

你的CSS类myownclassforpadding将不会被使用,因为从图书馆CSS是更具体的,因为它使用两个类sapMLIBsapMObjLItem。 你可以让你的CSS更具体是这样的:

.sapMLIB.sapMObjLItem.myownclassforpadding{ 
    padding: 0; 
    background-color: green; 
} 

看一看的JSBin example

1

尝试下面的选择覆盖默认的CSS。

.sapMLIB.sapMObjLItem.myownclassforpadding{ 
    padding-top: 0.25rem; 
    padding-bottom: 0.25rem; 
    background-color: green; 
} 
+0

为什么?有什么想法? – inetphantom

+0

使其更具体。请参阅此文档以了解详细信息:https://openui5beta.hana.ondemand.com/#docs/guide/723f4b2334e344c08269159797f6f796.html – Saddamhussain