0

I have two questions about HTML code.

This is the starting code.

<style>
th {
  height: 30px;
  background-color: #4970FF;
  color: white;
  font-size: 28px;
}

td {
  background-color: #FE4A49;
  color: #FAFAFA;
  font-size: 22px;
  vertical-align: middle;
}

table {
  margin: 0 auto;
}
</style>

<table>
  <thead>
    <tr>
      <th>" +
    XSNR +
    "</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>" +
    DGNR +
    "</td>
    </tr>
  </tbody>
</table>
 

  • Question one, as shown in the picture, I want the current effect (Before) where the blue background color extends to make the whole line blue, and the red background rows follow the length of the number of characters in the red text, to achieve the (After) effect. Currently both background colors are equal lengths.
  • Question two, if I want to add if code to append conditions, is this the way to write the code, or is there a more simplified method? Because I'm thinking if there are many if conditions, my code will become very long.(👇)

if a:=1 then

<style>
th {
  height: 30px;
  background-color: #4970FF;
  color: white;
  font-size: 28px;
}

td {
  background-color: #FE4A49;
  color: #FAFAFA;
  font-size: 22px;
  vertical-align: middle;
}

table {
  margin: 0 auto;
}
</style>

<table>
  <thead>
    <tr>
      <th>" +
    XSNR +
    "</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>" +
    DGNR +
    "</td>
    </tr>
  </tbody>
</table>

else

<style>
th {
  height: 28px;
  background-color: #4970FF;
  color: white;
  font-size: 22px;
}

table {
  margin: 0 auto;
}
</style>
<table>
  <thead>
    <tr>
      <th>" +
            XSNR +
            "</th>
    </tr>
  </thead>
</table>

Thank you for your reply.

2 replies

null
    • Fred
    • 2 mths ago
    • Reported - view

    For the 2nd question, you are correct your code can become very long if you repeat the table as well in your conditional statements. You can put your conditional statements inside the <style> part of the HTML code. Taking your example it could look something like:

    th {
      color: white;"+
      if a = 1 then
      "height: 30px;
      background-color: #4970FF;
      font-size: 28px;"
      else
      "height: 28px;
      background-color: #4970FF;
      font-size: 22px;"
      end
      +"
    }
    td {"+
      if a = 1 then
      "background-color: #FE4A49;
      color: #FAFAFA;
      font-size: 22px;
      vertical-align: middle;"
      end
      +"
    }
    

    So the body of your table stays the same but it will be modified by whatever Ninox solves for a = 1.

      • gold_cat
      • 2 mths ago
      • Reported - view

       I learned a lot from you.

Content aside

  • Status Answered
  • 2 mths agoLast active
  • 2Replies
  • 54Views
  • 2 Following