You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为jsPsychHtmlButtonResponse插件的按钮添加底部边距?

解决jsPsychHtmlButtonResponse按钮底部间距问题

下面提供几种可行的方法来调整按钮与页面底部的间距:

方法1:自定义类+外部CSS(推荐)

给trial对象添加css_classes属性指定自定义类,再通过外部CSS设置间距,这种方式不会干扰其他trial的样式:

var trial = {
  type: jsPsychHtmlButtonResponse,
  stimulus: '<p>  Stimulus Text </p>',
  choices: ['I agree to the terms and conditions of participation and would like to take part in the study.', 'I do not wish to participate in the study.'],
  css_classes: ['custom-button-spacing'] // 自定义类名
};

在页面的<style>标签中添加对应样式:

/* 给按钮容器添加底部内边距 */
.custom-button-spacing {
  padding-bottom: 50px; /* 按需调整数值 */
}

/* 或者给单个按钮添加底部外边距 */
.custom-button-spacing .jspsych-html-button-response-button {
  margin-bottom: 50px;
}

方法2:高优先级CSS直接覆盖

如果不想新增自定义类,可以用更具体的选择器或!important强制覆盖插件默认样式:

/* 针对按钮容器 */
.jspsych-html-button-response {
  padding-bottom: 60px !important;
}

/* 或者针对单个按钮 */
.jspsych-html-button-response-button {
  margin-bottom: 60px !important;
}

方法3:自定义按钮HTML结构

通过button_html参数直接给按钮内嵌底部边距样式,优先级最高:

var trial = {
  type: jsPsychHtmlButtonResponse,
  stimulus: '<p>  Stimulus Text </p>',
  choices: ['I agree to the terms and conditions of participation and would like to take part in the study.', 'I do not wish to participate in the study.'],
  button_html: '<button class="jspsych-html-button-response-button" style="margin-bottom: 50px;">%choice%</button>'
};

内容的提问来源于stack exchange,提问作者CapsLock

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 16:22:57