css - DIV 元素不接触

标签 css image html

我是 CSS 的新手,我需要帮助解决有关 CSS 和 DIVS 的问题。我在一个 div 标签中有一些 .JPG 切片,我需要它们无缝匹配,这样它看起来就像一个完整的文档。请看一下。

示例链接:(http://goo.gl/nmFDFB)

HTML

<section class="section_01">
  <p class="section"><img src="images/lp_01.jpg" name="lp01" hspace="0" vspace="0" border="0" id="lp_01"></p>
</section>

<section class="section_02">
  <p class="section"><img src="images/lp_02.jpg" name="lp02" border="0" id="lp_02"></p>
</section>

CSS

html {
    background: #fff;
    font-size: 100%;
    ms-text-size-adjust: 100%;
    webkit-text-size-adjust: 100%;
    min-width: 990px;
}
html, button, input, select, textarea {
    color: #000;
    font-family: Open Sans, Helvetica Neue, Arial, sans-serif;
    font-weight: 300;
}
body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1em;
    line-height: 0;
    margin: 0;
    padding: 0;
    padding-bottom: 0px;
}
/* base */

a {
    color: #31b7fa;
}
a:hover { /* add default link :hover class here */
}
div {
    top: 0px;
    clip: rect(0px,auto,auto,auto);
    position: absolute;
    margin-top: 0;
    margin-right: 0;
    margin-bottom: 0;
    margin-left: 0;
}
img {
    border: 0;
    padding: 0;
    margin: 0;
    width: 100%;
}
.left {
    float: left;
}
.right {
    float: right;
}
/* Sticky Navigation */
#sticky_navigation {
    z-index:600;
    position:fixed;
    top:0;
    margin:0;
    padding:0;
    background:url(../images/sticky.png) no-repeat top center;
    min-width:960px;
    height:105px;
    width:100%
}
#sticky_navigation a {
    display:block;
    height:105px;
    width:100%;
}

最佳答案

不要把图片放在p标签里;这是不必要的,p 标签通常有边距,这会导致您的问题。

另一种解决方案是将其放入您的 css 中:

p { margin: 0 }

这将消除边距。但就像我说的,我不推荐它。最好删除 p 标签。

此外,浏览器具有可供您使用的 Web 开发工具,它们会告诉您是什么导致了此类问题。例如,如果您使用的是 Chrome,ctrl+shift+j 将打开开发窗口。

关于css - DIV 元素不接触,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18244228/

相关文章:

html - 使用 FLWOR 的表内无序列表

javascript - jQuery 仅检查第一个表单

css - Chrome 与 Firefox/IE 中的字体大小不同

javascript - 翻页,当前站点居中

css - 修复屏幕中央 iframe 内的元素

html - 拉伸(stretch)图像作为背景

javascript - Firefox 浏览器中的 cssClass.selectorText 更改

python - 图像中的对象检测 (HOG)

java - 如何设置灰度图像的DPI信息?

javascript - 在图像上创建具有用户输入大小的网格