Contents

PowerApps HtmlText Common CSS Adjustments

featured-image.png
PowerApps HtmlText Common CSS Adjustments

Dcoration

Div Full Screen

css div full screen position: absolute;1

1
2
3
4
5
6
7
8
.box {
  background:red;
  position:absolute;
  top:0px;
  right:0px;
  bottom:0px;
  left:0px;
}

Center Horizontally and Vertically

css center horizontally and vertically2

  • not so good methods (won’t work on PowerApps)

    Using tables

    1
    2
    3
    4
    5
    6
    7
    
    <table>
        <tr>
            <td>
            Centered content
            </td>
        </tr>
    </table>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    table {
        width: 100%;
        height: 100%;
    }
    
    td {
        vertical-align: center;
        text-align: center;
    }
    

    Using FlexBox

    1
    
    <div>Centered content</div>
    
    1
    2
    3
    4
    5
    
    div {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
  • Suggested method which works on Powerapps correctly:

    Using translations

    1
    
    <div>Centered content</div>
    
    1
    2
    3
    4
    5
    6
    
    div {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    

Button Width Fit to The Text

css button width based on char count

as simple as width: fit-content;

If you are developing to a modern browser. https://caniuse.com/#search=fit%20content 3

Troubleshooting CSS

css style not working4

i.e. if you put the style below to button in HtmeText control, things below the font-family: "JetBrains Mono",monospace; won’t applied

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* CSS */
.button-30 {
  align-items: center;
  appearance: none;
  background-color: #FCFCFD;
  border-radius: 4px;
  border-width: 0;
  box-shadow: rgba(45, 35, 66, 0.4) 0 2px 4px,rgba(45, 35, 66, 0.3) 0 7px 13px -3px,#D6D6E7 0 -3px 0 inset;
  box-sizing: border-box;
  color: #36395A;
  cursor: pointer;
  display: inline-flex;
  font-family: "JetBrains Mono",monospace;
  height: 48px;
  justify-content: center;
  line-height: 1;
  list-style: none;
  overflow: hidden;
  padding-left: 16px;
  padding-right: 16px;
  position: relative;
  text-align: left;
  text-decoration: none;
  transition: box-shadow .15s,transform .15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
  will-change: box-shadow,transform;
  font-size: 18px;
}

since you need to change " to ' which you need to use Char(20)/Char(34) here instead. change it to font-family: "&Char(20)&"JetBrains Mono"&Char(20)&",monospace;.

Background Opacity CSS

you can either do it like

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<p style='
    position: absolute;
    text-align: center;
    background-color: transparentize(#e3e3e3,0.5);
    z-index: 1;
'>
    <i>You will be transfered to the external app <b>WFO</b></i>
</p>
<p style='
    position: absolute;
    text-align: center;
    background-color: #e3e3e3;
    opacity: 0.5;
'>
    <i>You will be transfered to the external app <b>WFO</b></i>
</p>

or use background-color: rgba(0, 0, 0, 0.5);5