简体   繁体   English

在检票口中获取CSS值

[英]Get CSS values in wicket

in my project i've faced a problem getting values of css attributes in wicket class, suppose we have some Panel 在我的项目中,我遇到了在检票口类中获取css属性值的问题,假设我们有一些面板

public final class ExamplePanel extends Panel {

  public ExamplePanel(String id) {
      super(id);
      add(new Label("someText", "hello"));
  }}

and html file for this file is 这个文件的html文件是

<html xmlns:wicket>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>ExamplePanel</title>
    <wicket:head>
        <link href="panel.css" rel="stylesheet"/>
        <script src="jquery.min.js"></script>
        <script src="jquery-ui.min.js"></script>

    </wicket:head>
</head>
<body>
    <wicket:panel>
        <div id="container" wicket:id="hello">
        </div>
    </wicket:panel>
</body>

and the following css 和以下CSS

#parentContainer{
 width:500px;
 height: 500px;
 background:RGB(57,51,51);
 position:relative;
}

i need to get values of css code, for example 例如,我需要获取CSS代码的值

public final class ExamplePanel extends Panel {

  public ExamplePanel(String id) {
      super(id);
      Label label = new Label("someText", "hello");
      add(label);
      // draft code
      //String height = label.getCssValue("height");
      // String position = label.getcssvalue("position");
  }}

Or any oher solution to get css values from this div? 还是从该div获取CSS值的其他解决方案?

As CSS is applied on the client side, your only chance would be to get the values by JavaScript (with the JQuery methods mentioned by Torr3nt being the easiest way that I know of) and post these values back to your App using Ajax. 由于CSS是在客户端应用的,因此,您唯一的机会就是通过JavaScript获取值(Torr3nt提到的JQuery方法是我所知道的最简单的方法),然后使用Ajax将这些值发布回您的App。

There is a description on how to call wicket from JavaScript here . 对于如何从JavaScript调用检票口的描述在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM