1

This is my current setup -

css

#exportButton {
    float: left;
    background-color: Green;
    height: 32px;
    margin-left: 3%;
    border-radius: 5px;
    margin-right: 1%;
    padding: 0px;
}

#exportButton img {
    height: 28px;
    padding: 3px;
    vertical-align: middle;
}


#exportLink {
    font-size: 16px;
    text-decoration:underline;
    color: white;
    padding: 3px;
}

HTML

 <body style="background-color:#E6E6FA">
    <span id="exportButton">
    <a id="exportLink" >HTML</a>
    <img src='http://s26.postimg.org/qpk50nhzp/icn_export.png' height="20px;">
    </span>

http://jsfiddle.net/NJ5Dz/

I need to remove whitespace between Export and the actual picture using CSS..How can I do that?

I tried various options of removing padding/margin but nothing works..

Pevara
  • 14,242
  • 1
  • 34
  • 47
user1050619
  • 19,822
  • 85
  • 237
  • 413

2 Answers2

1

You need to remove the right padding from the link and the left padding from the img.

#exportButton {
    float: left;
    background-color: Green;
    height: 32px;
    margin-left: 3%;
    border-radius: 5px;
    margin-right: 1%;
    padding: 0px;
}

#exportButton img {
    height: 28px;
    padding: 3px;
    vertical-align: middle;
    padding-left:0;
}


#exportLink {
    font-size: 16px;
    text-decoration:underline;
    color: white;
    padding: 3px;
    padding-right:0;
}

Fiddle Demo

blex
  • 24,941
  • 5
  • 39
  • 72
0

Example: http://jsfiddle.net/NJ5Dz/24/

By using a mix of reducing the parent's font-size and margin/padding edits I was able to place them side by side. I did add background color to the image to better show the image beside the text. It is a bit hacky but it works.

CSS:

#exportButton {
    float: left;
    background-color: Green;
    height: 32px;
    margin-left: 3%;
    border-radius: 5px;
    margin-right: 1%;
    padding: 0px;
    font-size: 0;
}

#exportButton img {
    height: 28px;
    padding-top: 3px;
    padding-bottom: 3px;
    margin-left: 0px;
    margin-top: -8px;
    vertical-align: middle;
    background-color: rgba(0,0,0,.4);
}


#exportLink {
    font-size: 16px;
    line-height: 28px;
    text-decoration:underline;
    color: white;
    padding-left: 3px;
    padding-top: 3px;
    padding-bottom: 3px;
}    
Darkaaja
  • 98
  • 8