- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个跨度的文本,但它们并不相邻。 (最后一段文字在前面一段文字的下面,但应该在前面一段文字的旁边。)
这是打印文本的代码:
var display_options_1 = `
<td><span id="A${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[0]}</span><span>${question.option_text[0]}</span></td>
<td><span id="B${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[1]}</span><span>${question.option_text[1]}</span></td>`;
var display_options_2 = `
<td><span id="C${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[2]}</span><span>${question.option_text[2]}</span></td>
<td><span id="D${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[3]}</span><span>${question.option_text[3]}</td>`;
It was easier to solve the problem with one
<span>
,<span id="C${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[ ]}
${question.option_text[ ]}
, but I need only
${question.options[]}
to be selected not${question.option_text[ ]}
最佳答案
改变这些行
<td><span id="A${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[0]}</span><span>${question.option_text[0]}
<td><span id="B${i}" class="${question.questionId}" onclick="onSelect(event)">${question.options[1]}</span><span>${question.option_text[1]}
这些
<td><span onclick="onSelect(event)" class="${question.questionId}" ><span id="A${i}" >${question.options[0]}</span><span>${question.option_text[0]}</span></span>
<td><span onclick="onSelect(event)" class="${question.questionId}"><span id="B${i}" >${question.options[1]}</span><span>${question.option_text[1]}</span></span>
在 .question1
上删除 width: 90%
在选择的第一个 child 上添加锁定/正确/不正确的类,例如
selection.firstElementChild.setAttribute('class', 'locked');
同时更改检查正确答案的行
if (currentQuestion.answer === e.currentTarget.firstElementChild.innerText) {
var x;
var questions = [{
questionId: "question1",
answerId: "C",
question: "1) जो भवनों में रहते हैं, वे है ?(C186506)",
options: ["A)", "B)", "C)", "D)"],
option_text: ["ज्योतिष्क ", "वैमानिक", "भवनपति ", "व्यंतर"],
answer: "C)",
locked: false
}];
var table = document.getElementById("test");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
cell1.colSpan = 2;
var i = 0;
function generateQuestion(question) {
// noinspection JSAnnotator
i += 1;
var newQuestion = `
<td colspan="2"><div class="question1" style="justify-content: center; width: 100%;">${question.question}`;
var display_options_1 = `
<td><span onclick="onSelect(event)" class="${question.questionId}" ><span id="A${i}" >${question.options[0]}</span><span>${question.option_text[0]}</span></span>
<td><span onclick="onSelect(event)" class="${question.questionId}"><span id="B${i}" >${question.options[1]}</span><span>${question.option_text[1]}</span></span>
`;
var display_options_2 = `
<td><span onclick="onSelect(event)" class="${question.questionId}" ><span id="C${i}" >${question.options[2]}</span><span>${question.option_text[2]}</span></span>
<td><span onclick="onSelect(event)" class="${question.questionId}"><span id="D${i}">${question.options[3]}</span><span>${question.option_text[3]}</span></span>
`;
var row2 = table.insertRow(1);
row2.innerHTML = newQuestion;
var row3 = table.insertRow(2);
setTimeout(() => {
row3.innerHTML = display_options_1;
}, 2000);
var row4 = table.insertRow(3);
setTimeout(function() {
row4.innerHTML = display_options_2;
}, 2000);
var points_display = "1";
var points_set = "237512";
var t_points = "237513";
var distance = "10";
}
function onSelect(e) {
var selection = e.currentTarget;
var questionId = e.currentTarget.className;
var currentQuestion = questions.find(function(q) {
return q.questionId == questionId;
});
if (currentQuestion.locked) {
alert("Question already answered");
} else if (currentQuestion.answer === e.currentTarget.firstElementChild.innerText) {
clearInterval(x);
//table.deleteRow(0);
//document.getElementById("timer").setAttribute('class', 'hidden_timer');
selection.firstElementChild.setAttribute('class', 'locked');
alert("Correct!!!");
currentQuestion.locked = true;
setTimeout(() => {
selection.setAttribute('class', 'correct');
}, 2000);
} else {
alert("Incorrect...");
clearInterval(x);
//table.deleteRow(0);
//document.getElementById("timer").setAttribute('class', 'hidden_timer');
selection.firstElementChild.setAttribute('class', 'locked');
currentQuestion.locked = true;
setTimeout(() => {
selection.firstElementChild.setAttribute('class', 'incorrect');
console.log(document.getElementById(currentQuestion.answerId + i));
document.getElementById(currentQuestion.answerId + i).setAttribute('class', 'correct');
}, 2000);
}
//generateQuestion(questions[i]);
}
function startTest() {
generateQuestion(questions[i]);
}
.correct {
display: flex;
align-items: center;
width: 90%;
height: auto;
min-height: 40px;
position: relative;
background: green;
color: white;
}
.correct::after {
content: "";
position: absolute;
left: -20px;
bottom: 0;
width: 0;
height: 0;
border-right: 20px solid green;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.correct::before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid green;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.lifeline {
background-color: pink;
color: white;
}
.incorrect {
display: flex;
align-items: center;
width: 90%;
height: auto;
min-height: 40px;
position: relative;
background: red;
color: white;
}
.incorrect::after {
content: "";
position: absolute;
left: -20px;
bottom: 0;
width: 0;
height: 0;
border-right: 20px solid red;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.incorrect::before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid red;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.locked {
display: flex;
align-items: center;
width: 90%;
height: auto;
min-height: 40px;
position: relative;
background: yellow;
color: white;
}
.locked::after {
content: "";
position: absolute;
left: -20px;
bottom: 0;
width: 0;
height: 0;
border-right: 20px solid yellow;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.locked::before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid yellow;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.timeout {
background-color: orange;
color: white;
}
.hidden_timer {
visibility: hidden;
display: none;
}
.visible {
visibility: visible !important
}
.timeout {
display: flex;
align-items: center;
width: 90%;
height: auto;
min-height: 40px;
position: relative;
background: orange;
color: white;
}
.timeout::after {
content: "";
position: absolute;
left: -20px;
bottom: 0;
width: 0;
height: 0;
border-right: 20px solid orange;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.timeout::before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid orange;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.question1 {
display: flex;
align-items: center;
height: auto;
min-height: 40px;
position: relative;
background: blue;
color: white;
}
.question1::after {
content: "";
position: absolute;
left: -20px;
bottom: 0;
width: 0;
height: 0;
border-right: 20px solid blue;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.question1::before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid blue;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.table_cstm {
border-collapse: separate;
border-spacing: 15;
/* Apply cell spacing */
table-layout: fixed
}
td:last-child div {
margin-left: auto;
}
/* Play header starts */
.button_cstm_quit {
background-color: red;
border: none;
color: white;
padding: 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 35px;
margin: 4px 2px;
cursor: pointer;
border-radius: 50%;
}
.button_cstm_quit:hover {
color: red;
font-weight: bold;
background: none;
border: 2px solid red;
}
.button_cstm_ll {
background-color: blue;
border: none;
color: white;
padding: 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 35px;
margin: 4px 2px;
cursor: pointer;
border-radius: 50%;
position: relative;
}
.button_cstm_ll:hover {
color: blue;
font-weight: bold;
background: none;
border: 2px solid blue;
}
.button_cst_pnts {
background-color: orange;
border: none;
color: white;
padding: 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 35px;
margin: 4px 2px;
cursor: pointer;
border-radius: 50%;
position: relative;
}
.button_cst_pnt:hover {
color: orange;
font-weight: bold;
background: none;
border: 2px solid orange;
}
.button_cstm_nxt {
background-color: blue;
border: none;
color: white;
padding: 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 35px;
margin: 4px 2px;
cursor: pointer;
border-radius: 50%;
position: relative;
}
.button_cstm_nxt:hover {
color: blue;
font-weight: bold;
background: none;
border: 2px solid blue;
}
.button_cstm_time {
background-color: #FF8C00;
border: none;
color: white;
padding: 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 35px;
margin: 4px 2px;
cursor: pointer;
border-radius: 50%;
}
.button_cstm_time:hover {
color: #FF8C00;
font-weight: bold;
background: none;
border: 2px solid #FF8C00;
}
#container_cstm {
width: 100%;
}
#left_cstm {
float: left;
width: 100px;
}
#right_cstm {
float: right;
width: 100px;
}
#center_cstm {
margin: 0 auto;
width: 100px;
}
#play_head {
display: flex;
/* establish flex container */
flex-direction: row;
/* default value; can be omitted */
flex-wrap: nowrap;
/* default value; can be omitted */
justify-content: space-between;
/* switched from default (flex-start, see below) */
}
.red_cross:before,
.red_cross:after {
position: absolute;
content: '';
top: -5px;
bottom: -5px;
width: 5px;
background: #ff0000;
left: 0;
right: 0;
margin: 0 auto;
}
.red_cross:before {
transform: skew(30deg);
}
.red_cross:after {
transform: skew(-30deg);
}
.disp_none {
display: none;
}
/* Play header ends */
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg" crossorigin="anonymous">
<body onload="startTest()">
<div class="container">
<table id="test" class="table table-responsive table_cstm" cellspacing="100">
</table>
</html>
关于javascript - 使用跨度,其他文本在下一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51054154/
这就是我现在正在做的事情。我在设计中使用 LESS CSS。我需要在指定输入之间放置 2 个跨度。所有元素的宽度都应为 100%。跨度应始终为 20px 宽度输入宽度可以根据屏幕宽度进行更改。谁能帮帮
我有一个包含文本和输入字段的跨度。我想知道是否可以让文本左对齐,输入字段右对齐。 NAME: .textBox{ display:inline-block; width:450px
我有这个按钮,我想让它在我点击“选择”时调用方法,在我点击“更改”时调用另一个方法: Select Change 我尝试输入 (click)="method()",但没有成功。我很
我正在开发聊天应用程序 (cordova),当我要在无法输入的表情符号后输入文本时,我在这段代码中遇到了问题 https://output.jsbin.com/radaref This i
很抱歉,如果这是一个非常愚蠢的问题,但我是一名开发人员,目前我的设计技能很少,我在个人网站上工作并且遇到了一个小问题。 我有一个带 ul 的顶部导航和 li元素。这些元素包含链接 . 跨度仅在链接悬
fiddle :https://jsfiddle.net/burz4g8s/4/ 我的 HTML 包含多行双按钮对。服务器端应用程序在 JSP 循环中输出按钮,所以我无法控制各个按钮——我不能使用 d
TextView.setLetterSpacing允许设置字母间距/字符间距。 有没有对应的CharacterStyle / span class允许在 TextView? 中的文本子集上设置字母间距
如何使洋红色矩形比红色矩形短 6 倍? GridLayout { id: gridLayout anchors.fill: parent flo
我最近开始使用 Twitter Bootstrap,但我似乎无法理解 span 的作用以及为什么会有不同的编号 span,例如 span4、span12?什么是偏移量以及它们何时使用? (有时与跨度一
我正在尝试构建一个 jQuery 函数来计算跨度中的总数 var sumnormaltotal = 0; $('span[id^="normaloffertotalspan"]').each(func
我想知道haskell如何评估以下表达式。 span (`elem` ['A'..'Z']) "BOBsidneyMORGANeddy" 结果是 ("BOB","sidneyMORGANeddy")
我有三个词,我想在第一个空格之后的内容周围添加一个跨度,所以 hello world 变成: hello world 和: hello world again 变成: hello world agai
我正在寻找纯 CSS 解决以下问题的方法。 考虑以下 HTML: Some text Some text 两者都是 正在显示元素 inline-block .如何在第二个 的左侧
如何将 Span 放置在其容器的底部? 我目前拥有的:http://jsfiddle.net/wRbax/2/ 我希望 .box 始终位于 .td 的底部 CSS .td { vertical
我试图在 li 中 float 两个 span。左跨度将有我的标签,在右跨度内我将构建一个具有嵌套跨度的图形。我有基本结构,但 chrome 将数字放在左侧跨度的末尾。我该如何解决这个问题? HTML
我有一个像这样的 JavaScript 变量: var text = "A businessman should be able to manage his business matters"; 我想
一些内容可编辑的框与其他框重叠,因此并非所有框都是可编辑的。我想保留与跨度位置中心对齐的文本,如下所示。我如何实现这一点? span { margin: auto; text-alig
我正在使用 WYSIWYG (InnovaEditor) 来编辑我网站上的内容,它适用于 Chrome、IE,主要适用于 Firefox,但 FF 有一个稍微令人讨厌的问题。我将 span 标签插入到
这是我的 html: Settings Export Import 和CSS: span.button { float:right; margin-righ
这里是问题所在:http://jsfiddle.net/STG22/3/ 我希望 span 不会分成两个不同的行(就像上面示例中的第三行一样)。我该怎么做? CSS: span { backg
我是一名优秀的程序员,十分优秀!