delphi 在TWebLabel上设置边框无效

xcitsw88  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(156)

我尝试在TWebLabel上这样做,给它一个5px的实心边框并给它着色。我尝试使用本文中提到的.setProperty(How to make TWebPanel have rounded corners?)我尝试在TWebLabel(lblHome)上这样做。

lblHome.ElementHandle.style.setProperty('border-top', '5px solid #da3b26');

字符串
但什么都没发生?

erhoui1w

erhoui1w1#

我刚刚在我这边测试了一下,它似乎可以工作。我做了一个空白的新应用程序,在表单上放置了一个TWebLabel,并将完全相同的代码添加到按钮单击事件中,它将border-top添加到标签中,如下图所示:
x1c 0d1x的数据
所以,也许你的标签有一些其他的属性,阻止了border-top的工作?
也许标签的边框/角超出了界限,所以边框就在那里,但你就是看不到它?
也可以删除标签并将其重新添加到表单中,然后重试。
下面的代码应该可以添加边框:

WebLabel1.ElementHandle.style.setProperty('border', '5px solid #da3b26');

字符串
但是你也可以用下面的代码添加一个边框:

var
  BorderStyle: String;
begin
  BorderStyle := WebLabel1.ElementHandle.getAttribute('style') + ';border: 5px solid #da3b26;';
  WebLabel1.ElementHandle.setAttribute('style',BorderStyle);
end;


如果你使用Bootstrap:

WebPanel1.ElementClassName := 'border border-5 border-danger';


border-top仅用于使用Bootstrap的顶部边框。

相关问题