希望在不创建新类的情况下将警告图标显示在正确的位置

Want to display the warning Icon in a correct position without creating new class

本文关键字:显示 图标 位置 警告 情况下 创建 新类 希望      更新时间:2023-09-26

我在UI屏幕的不同选项卡中收到错误消息。但是在其中一个选项卡中,警告图标没有显示在屏幕的中间。该屏幕选项卡包含2行错误消息,其他屏幕选项卡包含一行消息。

如果我将"style="margin-top:-6px"从-6更改为0,我将对所有选项卡使用公共类。选项卡将图标显示在正确的位置。但其他屏幕也会因此受到影响。

2行错误消息需要0px,其他屏幕需要-6px。那么,我如何才能做到这一点,为每个选项卡创建单独的类

<div class="error-message-container" ng-show="workloadConfigurationErrorMessage != ''" style="height: auto;">
            <div class="error-message-content" >
                <img src="app-vrm/img/error-warning-icon.png" style="margin-top:-6px"/>
                <p>
                    <span translate="workloadconfiguration.view.SYSTEM_WARNING"></span><p> {{workloadConfigurationErrorMessage}}</p>
                </p>
            </div>
        </div>

而不是

style="margin-top:-6px"

给出

ng-style="myStyle"

并且在相应的控制器中给出

$scope.myStyle={};
$scope.myStyle.marginTop="-6px"; or $scope.myStyle.marginTop="0px";

这是可以应用的。霍普,我回答了你的问题。