[SalesForce] aligning elements in same line in lightning component

I am trying to align 2 elements in the same line next to each other, but having hard time. And i know this is kind of a simple question that can be googled. But i simply can't seem to do it.

Here is the code –

<div>
  <c:PF_InputCheckbox id="pf_nhw_contractor_submit_acknowledged" value="{!v.acknowledged}"/>
  I affirm I have read and understand the policy.
</div>

Here is the output –
enter image description here

The component c:PF_InputCheckbox is that checkbox thingy seen here. I want the text right next to it, not below it.

I have tried assigning class slds-show_inline-block to container div, but it still shows the checkbox and the text in two separate lines.

Best Answer

There are several ways of doing this. One of them would be using an slds grid

<div class="slds-grid">
  <div class="slds-col"> Component HERE</div>
  <div class="slds-col"> Text HERE </div>
</div>

would render the following:

enter image description here you can then chose to align your text to the left, or right, again using slds. I encourage you to read the the SLDS documentation and or to do the SLDS Trailhead Module to expand your knowledge on the subject.

Related Topic