为什么这些元素不显示内联块?

时间:2015-08-04 19:06:42

标签: javascript css image

我试图让它显示一个图像(或其他对象),然后在一行(连续)中提示左图像(或其他对象)。为什么要在自己的行上显示每个图像?

var to_add = "<div>";
// add the left stimulus

if (trial.west_is_html) {
    to_add+="<img id='jspsych-single-stim-stimulus-west' src="+trial.a_path_west.src +" height="+trial.a_path_west.height+" width="+trial.a_path_west.width+" style=display:'inline-block'>";
}

else {
      to_add+="<div id='jspsych-single-stim-stimulus-west'>"+trial.a_path_west+"</div>";
}

//show prompt if there is one
if (trial.prompt !== "") {
    to_add+="<div style=disaply'inline-block'>" + trial.prompt+ " </div>";
}

// show the right stimulus
if (trial.east_is_html) {
   to_add+="<img id='jspsych-single-stim-stimulus-east' src="+trial.a_path_east.src +" height="+trial.a_path_east.height+" width="+trial.a_path_east.width+" style=display:'inline-block'>";
}
else {
     to_add+="<div id='jspsych-single-stim-stimulus-east'>"+trial.a_path_east+"</div>";
}

to_add+="</div>"

display_element.append(to_add);

谢谢!

1 个答案:

答案 0 :(得分:2)

你有拼写错误:

style=display:'inline-block'

应该在所有地方:

style='display:inline-block'