如果查看图像,可以看到the box that contains #1 has a little margin to its right and then following that comes the club picture
。我希望图像将其自身附加到左侧的div,因此它们之间没有空间。我已经尝试了一切,但无法弄明白。 我是一个很棒的CSS新手FYI
我仍然是CSS的新手,但我正试图将图像向左推,并将其自身附加到包含内部数字的框中
以下是我生成的HTML:
<table class="featuredclub" id="featuredclub-comments">
<tbody>
<tr>
<td width="10%" class="rating"><div class="ratingnumber">
<span class="ratingpositiontext"><span
style="margin-top: 15px">#8</span></span>
</div></td>
<td width="15%" style="margin-left: 0px; margin-top: 1px"
class="imagetd"><div class="ratingimage">
<div style="margin-top: 6px">
<img style="height: 80px; width: 80px" class="featuredavatar"
src="/img/featuredtmp.png">
</div>
</div></td>
<td width="75%" style="text-align: left; margin-left: 10px"><span
class="featuredclubname">Alex's</span><span
class="featuredclubaddress">584 Washington st</span><span
class="featuredclublocality">Stoughton, MA 02072</span><span
class="featuredclubphone">781.344.2175</span></td>
</tr>
</tbody>
</table>
这是我的CSS:
@CHARSET "ISO-8859-1";
span.value {
margin-right:-10px;
}
.viewallbutton{
display:inline;
margin-top:2px;
margin-left:2px;
}
h2.sectionlabel{
display:inline-block;
}
.banner{
position: relative;
background-color: #ffffff;
width: 1200px;
height: 66px;
margin: 0px auto;
padding-top:15px;
padding-bottom:0px;
padding-left:25px;
padding-right:25px;
box-sizing: border-box;
/**
border-top: 1px solid #d0d0d0;
border-left: 1px solid #d0d0d0;
border-right: 1px solid #d0d0d0;
border-bottom:none;
*/
border:0px;
border-bottom:1px solid #f0f0f0;
font: 14px/20px Arial, Helvetica, Sans-serif;
}
.banner h2{
font: 32px/32px DinWebCond, Sans-serif;
color: #120006;
margin: 0px 0px 5px 0px;
text-transform: uppercase;
padding-top:5px;
padding-bottom:15px;
}
div.banner-container1{
width:90%;
height:50px;
background-color:#f0f0f0;
padding-left:25px;
}
div.banner-container2{
width:90%;
height:50px;
background-color:#f0f0f0;
padding-left:25px;
/**padding-left:25px;*/
}
div.banner-container div.innerclubbox{
background-color:#ffffff;
}
.tabledatalabel{
font: 20px/24px DinWebCond, Sans-serif;
color: #606060;
margin: 0px 0px 5px 0px;
/**text-transform:capitalize;*/
padding-top:5px;
}
.row {
position: relative;
/**height: 750px;*/
height: 450px;
background-color: #ffffff;
width: 1200px;
margin: 0px auto;
/**padding-top:20px;*/
padding-top:10px;
padding-bottom:0px;
padding-left:0px;
/**padding-right:25px;*/
box-sizing: border-box;
/**border: 1px solid #d0d0d0;*/
font: 14px/20px Arial, Helvetica, Sans-serif;
}
p .clear{
clear:both;
}
.section1 .featuredclub{
width:100%;
height:100px;
background-color:#f0f0f0;
font:14px/20px AdlWebNorm, Sserif;
}
.section1 table.featuredclub,
.section2 table.featuredclub{
width:100%;
height:100px;
background-color:#f0f0f0;
font:14px/20px AdlWebNorm, Sserif;
margin-top:-5px;
/**margin-left:25px;*/
margin-bottom:10px;
}
.section1 table.featuredclub .rating,
.section2 table.featuredclub .rating {
/**margin-top:-5px;
margin-left:25px;
margin-bottom:10px;*/
/**background-color:#ffffff;*/
width:71px;
height:71px;
}
.section1 table.featuredclub .image,
.section2 table.featuredclub .image {
/**margin-top:-5px;
margin-left:25px;
margin-bottom:10px;*/
/**background-color:#ffffff;*/
width:71px;
height:71px;
margin-left:0px;
}
.ratingnumber{
font-size: 42px;
margin-left:14px;
width:80px;
height:80px;
background-color:#ffffff;
/**padding-left:15px;
padding-top:15px;*/
}
.section1 .featuredclub span,
.section2 .featuredclub span {
line-height: 85px;
}
.ratingpositiontext{
margin-right:15px;
margin-top:55px;
}
.section1 table.featuredclub .rating div.ratingimage,
.section2 table.featuredclub .rating div.ratingimage{
font-size: 26px;
margin-left:0px;
width:80px;
height:80px;
background-color:#ffffff;
}
.section1 .featuredclub .featuredtext{
width:100%;
height:100px;
background-color:#f0f0f0;
font:14px/20px AdlWebNorm, Sserif;
display:inline-block;
}
.section1 .featuredclub span p.rating{
margin-top:-5px;
margin-left:25px;
margin-bottom:10px;
background-color:#ffffff;
width:71px;
height:71px;
/**display:inline;*/
}
.section1 .featuredclub span p.text{
margin-top:-5px;
margin-left:5px;
margin-bottom:10px;
background-color:#ffffff;
/**width:71px;*/
height:71px;
display:inline;
}
.section2 .featuredclub{
width:100%;
height:100px;
background-color:#f0f0f0;
font:14px/20px AdlWebNorm, Sserif;
}
.section1 .featuredclub span.featuredclubname,
.section2 .featuredclub span.featuredclubname
{
clear:both;
color:#120006;
float:left;
font: 22px/22px DinWebCond, Sans-serif;
}
.section1 .featuredclub span.featuredclubaddress,
.section2 .featuredclub span.featuredclubaddress
{
clear:both;
float:left;
font: 14px/20px AdlWebNorm, Serif;
color: #000000;
}
.section1 .featuredclub span.featuredclublocality,
.section2 .featuredclub span.featuredclublocality
{
clear:both;
float:left;
font: 14px/20px AdlWebNorm, Serif;
color: #000000;
}
.section1 .featuredclub span.featuredclubphone,
.section2 .featuredclub span.featuredclubphone
{
clear:both;
float:left;
font: bold 12px/12px Arial, Helvtica, Sans-serif;
margin-top:2px;
}
.section2 .featuredclub span p.rating,
{
margin-top:-5px;
margin-left:25px;
margin-bottom:10px;
background-color:#ffffff;
width:71px;
height:71px;
}
.section1 .featuredclub p.rating img.featuredavatar{
margin-top:-27px;
width:70px;
height:70px;
margin-left:69px;
}
.section2 .featuredclub p.rating img.featuredavatar{
margin-top:-27px;
width:70px;
height:70px;
margin-left:69px;
}
.section1 .featuredclub span p.rating span.rating-number-box
{
text-align:center;
font-size: 36px;
color:#bd673a;
margin-top:20px;
}
.section2 .featuredclub span p.rating span.rating-number-box
{
text-align:center;
font-size: 36px;
color:#bd673a;
margin-top:20px;
}
.section1 .featuredclub span{
/**margin-left:25px;*/
}
.section2 .featuredclub span{
/**margin-left:25px;*/
}
.section1 {
width:50%;
/**border-right: 1px solid #d0d0d0;*/
float:left;
box-sizing: border-box;
}
td {
font:14px/20px AdlWebNorm, Sserif;
}
.section2 {
width:50%;
/**border-right: 1px solid #d0d0d0;*/
float:left;
box-sizing: border-box;
}
.section1 h2{
font: 22px/24px DinWebCond, Sans-serif;
color: #120006;
margin: 0px 0px 5px 0px;
text-transform: uppercase;
padding-left:17px;
padding-bottom:10px;
}
.section2 h2{
font: 22px/24px DinWebCond, Sans-serif;
color: #120006;
margin: 0px 0px 5px 0px;
text-transform: uppercase;
padding-left:17px;
padding-bottom:10px;
}
td {
text-align:right;
}
td.imagetd{
text-align:left;
}
.progress-bar .horizontal {
float: left;
height: 45px;
width: 100%;
/**padding: 12px 0;*/
}
.progress-track {
position: relative;
width: 30%;
height: 13px;
background: #FFFFFF;
float:right;
margin-left:-20px;
}
.progress-fill {
position: relative;
background: #2272af;
height: 13px;
width: 50%;
color: #2272af;
text-align: center;
font-family: "Lato","Verdana",sans-serif;
font-size: 12px;
line-height: 20px;
border-radius:0px 4px 4px 0px;
/**border-radius:0px 0px 0px 0px;*/
/**border-radius-top-right:5x;
border-radius-bottom-right:5px;*/
}
/**tr td { padding-top: 1px }*/
.ratingpositiontext{
color:#e8620d;
font: 42px/44px DinWebCond, Sans-serif;
}
我不太清楚如何解决这个问题。我已经尝试过,无法弄清楚如何将图像附加到数字div
感谢。
答案 0 :(得分:0)
差距可能来自表格单元格之间的间距。尝试使用CSS:
table {
border-spacing: 0;
border-collapse: collapse;
}
td { margin: 0; }
或蛮力方法:
<table cellspacing="0">
更新:为我修好:
.featuredclub { border-collapse: collapse; }
td { padding: 0; }
答案 1 :(得分:0)
@CHARSET "ISO-8859-1";
span.value {
margin-right: -10px;
}
.viewallbutton {
display: inline;
margin-top: 2px;
margin-left: 2px;
}
h2.sectionlabel {
display: inline-block;
}
.banner {
position: relative;
background-color: #ffffff;
width: 1200px;
height: 66px;
margin: 0px auto;
padding-top: 15px;
padding-bottom: 0px;
padding-left: 25px;
padding-right: 25px;
box-sizing: border-box;
/**
border-top: 1px solid #d0d0d0;
border-left: 1px solid #d0d0d0;
border-right: 1px solid #d0d0d0;
border-bottom:none;
*/
border: 0px;
border-bottom: 1px solid #f0f0f0;
font: 14px/20px Arial, Helvetica, Sans-serif;
}
.banner h2 {
font: 32px/32px DinWebCond, Sans-serif;
color: #120006;
margin: 0px 0px 5px 0px;
text-transform: uppercase;
padding-top: 5px;
padding-bottom: 15px;
}
div.banner-container1 {
width: 90%;
height: 50px;
background-color: #f0f0f0;
padding-left: 25px;
}
div.banner-container2 {
width: 90%;
height: 50px;
background-color: #f0f0f0;
padding-left: 25px;
/**padding-left:25px;*/
}
div.banner-container div.innerclubbox {
background-color: #ffffff;
}
.tabledatalabel {
font: 20px/24px DinWebCond, Sans-serif;
color: #606060;
margin: 0px 0px 5px 0px;
/**text-transform:capitalize;*/
padding-top: 5px;
}
.row {
position: relative;
/**height: 750px;*/
height: 450px;
background-color: #ffffff;
width: 1200px;
margin: 0px auto;
/**padding-top:20px;*/
padding-top: 10px;
padding-bottom: 0px;
padding-left: 0px;
/**padding-right:25px;*/
box-sizing: border-box;
/**border: 1px solid #d0d0d0;*/
font: 14px/20px Arial, Helvetica, Sans-serif;
}
p .clear {
clear: both;
}
.section1 .featuredclub {
width: 100%;
height: 100px;
background-color: #f0f0f0;
font: 14px/20px AdlWebNorm, Sserif;
}
.section1 table.featuredclub,
.section2 table.featuredclub {
width: 100%;
height: 100px;
background-color: #f0f0f0;
font: 14px/20px AdlWebNorm, Sserif;
margin-top: -5px;
/**margin-left:25px;*/
margin-bottom: 10px;
}
.section1 table.featuredclub .rating,
.section2 table.featuredclub .rating {
/**margin-top:-5px;
margin-left:25px;
margin-bottom:10px;*/
/**background-color:#ffffff;*/
width: 71px;
height: 71px;
}
.section1 table.featuredclub .image,
.section2 table.featuredclub .image {
/**margin-top:-5px;
margin-left:25px;
margin-bottom:10px;*/
/**background-color:#ffffff;*/
width: 71px;
height: 71px;
margin-left: 0px;
}
.ratingnumber {
font-size: 42px;
margin-left: 14px;
width: 80px;
height: 80px;
background-color: #ffffff;
/**padding-left:15px;
padding-top:15px;*/
}
.section1 .featuredclub span,
.section2 .featuredclub span {
line-height: 85px;
}
.ratingpositiontext {
/*margin-right: 15px;*/
margin-top: 55px;
}
.section1 table.featuredclub .rating div.ratingimage,
.section2 table.featuredclub .rating div.ratingimage {
font-size: 26px;
margin-left: 0px;
width: 80px;
height: 80px;
background-color: #ffffff;
}
.section1 .featuredclub .featuredtext {
width: 100%;
height: 100px;
background-color: #f0f0f0;
font: 14px/20px AdlWebNorm, Sserif;
display: inline-block;
}
.section1 .featuredclub span p.rating {
margin-top: -5px;
margin-left: 25px;
margin-bottom: 10px;
background-color: #ffffff;
width: 71px;
height: 71px;
/**display:inline;*/
}
.section1 .featuredclub span p.text {
margin-top: -5px;
margin-left: 5px;
margin-bottom: 10px;
background-color: #ffffff;
/**width:71px;*/
height: 71px;
display: inline;
}
.section2 .featuredclub {
width: 100%;
height: 100px;
background-color: #f0f0f0;
font: 14px/20px AdlWebNorm, Sserif;
}
.section1 .featuredclub span.featuredclubname,
.section2 .featuredclub span.featuredclubname {
clear: both;
color: #120006;
float: left;
font: 22px/22px DinWebCond, Sans-serif;
}
.section1 .featuredclub span.featuredclubaddress,
.section2 .featuredclub span.featuredclubaddress {
clear: both;
float: left;
font: 14px/20px AdlWebNorm, Serif;
color: #000000;
}
.section1 .featuredclub span.featuredclublocality,
.section2 .featuredclub span.featuredclublocality {
clear: both;
float: left;
font: 14px/20px AdlWebNorm, Serif;
color: #000000;
}
.section1 .featuredclub span.featuredclubphone,
.section2 .featuredclub span.featuredclubphone {
clear: both;
float: left;
font: bold 12px/12px Arial, Helvtica, Sans-serif;
margin-top: 2px;
}
.section2 .featuredclub span p.rating,
{
margin-top: -5px;
margin-left: 25px;
margin-bottom: 10px;
background-color: #ffffff;
width: 71px;
height: 71px;
}
.section1 .featuredclub p.rating img.featuredavatar {
margin-top: -27px;
width: 70px;
height: 70px;
margin-left: 69px;
}
.section2 .featuredclub p.rating img.featuredavatar {
margin-top: -27px;
width: 70px;
height: 70px;
margin-left: 69px;
}
.section1 .featuredclub span p.rating span.rating-number-box {
text-align: center;
font-size: 36px;
color: #bd673a;
margin-top: 20px;
}
.section2 .featuredclub span p.rating span.rating-number-box {
text-align: center;
font-size: 36px;
color: #bd673a;
margin-top: 20px;
}
.section1 .featuredclub span {
/**margin-left:25px;*/
}
.section2 .featuredclub span {
/**margin-left:25px;*/
}
.section1 {
width: 50%;
/**border-right: 1px solid #d0d0d0;*/
float: left;
box-sizing: border-box;
}
td {
font: 14px/20px AdlWebNorm, Sserif;
}
.section2 {
width: 50%;
/**border-right: 1px solid #d0d0d0;*/
float: left;
box-sizing: border-box;
}
.section1 h2 {
font: 22px/24px DinWebCond, Sans-serif;
color: #120006;
margin: 0px 0px 5px 0px;
text-transform: uppercase;
padding-left: 17px;
padding-bottom: 10px;
}
.section2 h2 {
font: 22px/24px DinWebCond, Sans-serif;
color: #120006;
margin: 0px 0px 5px 0px;
text-transform: uppercase;
padding-left: 17px;
padding-bottom: 10px;
}
td {
text-align: right;
}
td.imagetd {
text-align: left;
}
.progress-bar .horizontal {
float: left;
height: 45px;
width: 100%;
/**padding: 12px 0;*/
}
.progress-track {
position: relative;
width: 30%;
height: 13px;
background: #FFFFFF;
float: right;
margin-left: -20px;
}
.progress-fill {
position: relative;
background: #2272af;
height: 13px;
width: 50%;
color: #2272af;
text-align: center;
font-family: "Lato", "Verdana", sans-serif;
font-size: 12px;
line-height: 20px;
border-radius: 0px 4px 4px 0px;
/**border-radius:0px 0px 0px 0px;*/
/**border-radius-top-right:5x;
border-radius-bottom-right:5px;*/
}
/**tr td { padding-top: 1px }*/
.ratingpositiontext {
color: #e8620d;
font: 42px/44px DinWebCond, Sans-serif;
}
<table class="featuredclub" id="featuredclub-comments" border=1 cellpadding=0 cellspacing=0>
<tbody>
<tr>
<td class="rating">
<div class="ratingnumber">
<span class="ratingpositiontext"><span style="margin-top: 15px">#8</span></span>
</div>
</td>
<td style="margin-left: 0px; margin-top: 1px" class="imagetd">
<div class="ratingimage">
<div style="margin-top: 6px">
<img style="height: 80px; width: 80px" class="featuredavatar" src="http://placehold.it/80x80">
</div>
</div>
</td>
<td style="text-align: left; margin-left: 10px">
<div class="featuredclubname">Alex's</div>
<div class="featuredclubaddress">584 Washington st</div>
<div class="featuredclublocality">Stoughton, MA 02072</div>
<div class="featuredclubphone">781.344.2175</div>
</td>
</tr>
</tbody>
</table>
答案 2 :(得分:0)
如果要从当前实现中删除填充,则需要添加:
/* remove padding between cells */
table {
border-collapse: collapse;
}
/* remove padding within cells */
td {
padding: 0
}
最终你应该重新考虑在这里使用表格,这不显示表格数据,你可以轻松实现这一点,而无需使用浮动或内联元素:How to convert a <table> to <div>s。