简体   繁体   English

将复选框与段落文本内联放置

[英]Place checkbox inline with paragraph text

How can i put that checkbox inline with the text? 如何将该复选框与文本内联?

The html code is: html代码是:

<div class="checkbox checkbox_allow_div"><label class="label_300"><input type="checkbox" name="allow" value="1" class="allow_checkbox"><?php echo gdpr_text('gdpr_order_text'); ?></label></div>

The text, that i echo with php, its comeing from sql table, and its writed in a ckeditor on the admin page. 我用php回显的文本,它来自sql表,并写在管理页面上的ckeditor中。 Ckeditor put the text automatically in <p> tags. Ckeditor会将文本自动放入<p>标记中。

I cant put the checkbox code into that texts html code, bacause the user is writing the text on the admin page, so its always dynamic. 我不能将复选框代码放入该文本html代码中,因为用户是在管理页面上编写文本,因此它始终是动态的。

在此处输入图片说明

First, make sure that the checkbox is not defined as a block with: 首先,请确保未通过以下方式将复选框定义为块:

.checkbox_allow_div {
  display: inline-block'
}

then, you can style the label that is around the checkbox and the text's p tag with: 然后,您可以使用以下样式设置复选框周围的标签和文本的p标签的样式:

label {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}

More information on Flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/ 有关Flexbox的更多信息: https ://css-tricks.com/snippets/css/a-guide-to-flexbox/

Add display:inline-block for input and paragraph. 添加display:inline-block用于输入和段落。

 .checkbox input, .checkbox p { display: inline-block } 
 <div class="checkbox checkbox_allow_div"> <label class="label_300"> <input type="checkbox" name="allow" value="1" class="allow_checkbox"> <p>Random Text</p> </label> </div> 

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

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