gpt4 book ai didi

javascript - 无法从 Javascript 代码中删除空格

转载 作者:太空宇宙 更新时间:2023-11-03 17:34:18 24 4
gpt4 key购买 nike

我很难在我教授的网站上使用 Javascript 获得一个 div 以与网站的其余部分适本地隔开。我已经尝试调整边距并在其他 Stackoverflow.com 线程(例如 CSS: Center block but left align contents )上提出一些建议,但似乎都没有用。

基本上,我试图让链接像其他页面一样在页面上更靠前。

我有的是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="ecl.css" />
<title>Sarah Lawrence College: Research</title>
<script type="text/javascript">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}
</script>
</head>

<body>
<div id="header"><img src="images/celab-header-reduced.jpg" /></div>
<div id="navigation">
<ul>
<li><a href="index.html">About</a></li>
<li><a href="research.html">Research</a></li>
<li><a href="teaching.html">Teaching</a></li>
<li><a href="publications.html">Publications</a></li>
<li><a href="members.html">Lab Members</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div id="researchcontent">
<ul>
<li>
<div class="showhide"><a href="javascript:hideshow(document.getElementById('ptsd'))">
<h1>Posttraumatic Stress Disorder (PTSD)</h1>
</a></div>
<div id="ptsd">We are currently a series of studies using cognitive and brain imaging techniques to examine the impact of combat trauma on memory and emotion. These studies focus on how perceptions of one’s self impact cognitive, behavioral, and biological processes associated with recovery from combat trauma.</div>
</li>

依此类推...以...结尾

</li>
</ul>
</p>
</div>
</body>
</html>

对于我拥有的 CSS:

/* Structure */

div#content {
width:600px;
float:center;
margin:auto;
}


div#navigation {
float:left;
margin:auto auto;
}

div#footer {
clear:both;
text-align:center;
font-size:14px;
font-family:Times New Roman, Times, serif;
}

div#researchcontent {
width:600px;
float:center;
margin:auto;
}

/* Research */

div.showhide {
clear:both;
margin:0px;
}

div#ptsd {
display:none;
}

div#memory {
display:none;
}

div#futureself {
display:none;
}

div#socialremembering {
display:none;
}

div#trauma {
display:none;
}

最佳答案

将以下 CSS 添加到现有样式表的底部。这些样式将使查看导致不需要的空间的原因变得非常容易。

* {
background: #000 !important;
color: #0f0 !important;
outline: solid #f00 1px !important;
}

然后,使用网络浏览器的开发工具相应地调整样式。

关于javascript - 无法从 Javascript 代码中删除空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29996362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com