Forum Moderators: not2easy
<div class="row"><nobr>
div.row {white-space: nowrap;} div table div table {font-size: inherit; font-family: inherit; line-height: inherit;} What does your current CSS say about div and/or table div?
Font size really shouldn't be an issue, since your images are surely taller than a typical row of text in any size you could name.
If an image is smaller than the font (line height) then an empty space equal to the difference must appear above the image.
table {font-size: inherit; font-family: inherit; line-height: inherit;}
div.row {white-space: nowrap;}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="UTF-8" />
<title>test</title>
<style>
* {
margin:0;
padding:0;
}
.row {
height: 50px;
overflow:hidden;
}
.cell {
height: 50px;
width: 50px;
float: left;
}
#wrapper {
min-width: 150px;
}
</style>
</head>
<body>
<div id="wrapper">
<div class="row">
<div class="cell" style="background-image: url('img11.png')"></div>
<div class="cell" style="background-image: url('img12.png')"></div>
<div class="cell" style="background-image: url('img13.png')"></div>
</div>
<div class="row">
<div class="cell" style="background-image: url('img21.png')"></div>
<div class="cell" style="background-image: url('img22.png')"></div>
<div class="cell" style="background-image: url('img23.png')"></div>
</div>
<div class="row">
<div class="cell" style="background-image: url('img31.png')"></div>
<div class="cell" style="background-image: url('img32.png')"></div>
<div class="cell" style="background-image: url('img33.png')"></div>
</div>
</div>
</body>
</html>>
when written the normal way, two pixels of empty space is added to the right side of each image.
<img src="blank.png"><img src="blank.png"><img src="blank.png">
<img src="blank.png"><img src="blank.png"><img src="blank.png"> <img src="blank.png"> <img src="blank.png"> In another thread regarding this same issue it was your advice that I set my FONT SIZE to something that definitely renders smaller than my images because <snip>
I honestly don't get why you continue to not want to listen, and refuse to take a step back from the stuff that doesn't work and into a new world.
It all boils down to one simple fact: an image is by default an inline element, just like a word of text it sits on a line, allowing space between words (your horizontal gaps) and allowing space for descenders on that line of text (your vertical gaps).
Well, I'm going to explain this whether you want me to or not...
The spaces between words is also determined by the font -- not any coding you do.
The CSS3 overflow-x and overflow-y properties are partially supported in Internet Explorer for windows versions 5 and 6 and fully supported in Internet Explorer versions 7 & 8. Safari 3+, Chrome 2+, Firefox 2+ and Opera 9.5+ all support these properties.
.row {
white-space: nowrap;
}
.row {
white-space: nowrap;
line-height: 0;
}
Putting icons on a map ?
You don't need a grid for that. You can position the icons anywhere...
Since images are INLINE they can not overlap.
VALID code: use a validator such as [validator.nu...] or [validator.w3.org...]
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="UTF-8" />
<title>test</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="UTF-8" />
<title>test</title>
<style>
* {
margin:0;
padding:0;
}
.map {
height: 480px;
width: 640px;
background-image: url('map.png');
}
</style>
</head>
<body>
<div class="map">
<a class="icon gas" href="/gas?1"></a>
<a class="icon gas" href="/gas?2"></a>
<a class="icon lodging" href="/motel?1"></a>
<a class="icon lodging" href="/motel?2"></a>
<a class="icon food" href="/food?1"></a>
<a class="icon food" href="/food?2"></a>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="UTF-8" />
<title>test</title>
<style>
* {
margin:0;
padding:0;
}
.map {
height: 480px;
width: 640px;
position: relative;
background-image: url('map.png');
}
.icon {
position: absolute;
width: 20px;
height: 20px;
display:block;
background:red;
}
</style>
</head>
<body>
<div class="map">
<a class="icon gas" style="top: 100px; left: 100px" href="/gas?1"></a>
<a class="icon gas" style="top: 120px; left: 200px" href="/gas?2"></a>
<a class="icon lodging" style="top: 140px; left: 300px" href="/motel?1"></a>
<a class="icon lodging" style="top: 160px; left: 400px" href="/motel?2"></a>
<a class="icon food" style="top: 180px; left: 500px" href="/food?1"></a>
<a class="icon food" style="top: 200px; left: 600px" href="/food?2"></a>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="UTF-8" />
<title>test</title>
<style>
* {
margin:0;
padding:0;
}
.map {
height: 480px;
width: 640px;
position: relative;
background-image: url('map.png');
}
.icon {
position: absolute;
width: 20px;
height: 20px;
display:block;
}
.gas {
background-image: url('red.png');
}
.lodging {
background-image: url('green.png');
}
.food {
background-image: url('blue.png');
}
</style>
</head>
<body>
<div class="map">
<a class="icon gas" style="top: 100px; left: 100px" href="/gas?1"></a>
<a class="icon gas" style="top: 120px; left: 200px" href="/gas?2"></a>
<a class="icon lodging" style="top: 140px; left: 300px" href="/motel?1"></a>
<a class="icon lodging" style="top: 160px; left: 400px" href="/motel?2"></a>
<a class="icon food" style="top: 180px; left: 500px" href="/food?1"></a>
<a class="icon food" style="top: 200px; left: 600px" href="/food?2"></a>
</div>
</body>
</html>
I'll have to go back and look at what the difference is between a sprite (as used in a Web page) and say a normal PNG image. I know about sprites as a CGI animator, where a sprite is usually just a small, low-res, low-depth 2D image which, because of its small file size, can be processed more swiftly for rendering in a 3D enviornment where action is taking place -- can't imagine why something like a sprite would be used in a Web page, which is usually a static, 2D world.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Brooklyn Map</title>
<style type="text/css">
html {
scrollbar-3dlight-color:#C6C6C6;
scrollbar-arrow-color:#FFFFFF;
scrollbar-face-color:#5A5A5A;
scrollbar-track-color:#1F1F1F;
scrollbar-highlight-color:#808080;
scrollbar-shadow-color:#484848;
scrollbar-darkshadow-Color:202020;
}
/* Moved all presentational attributes out of body element. */
body {
color: #000;
font-family: Arial, Helvetique, sans-serif;
font-size: x-small;
margin: 0;
padding: 0;
}
/* This container has the map background. It has been sized to the
* dimensions of the background image. It has position relative so
* absolutely positioned images that get placed on the map are relative
* to this container. */
.mapContent {
background: #484848 url('BROOKLYN_map.png');
width: 1427px;
height: 1415px;
overflow: auto;
position: relative;
}
/* This container has the client list. It is positioned within the map
* container. */
.clientList {
background-color: #b5c7e0;
border: 2px solid #93a6bc;
float: left;
margin: 1em;
width: 200px;
}
/* This is the list of clients. List markers have been removed. */
.clientList ul {
list-style: none;
list-style-position: inside;
margin: 0;
padding: 0;
}
/* This is the list item which contains client info. */
.clientList li {
padding: .5em;
}
/* Moved all presentational attributes out of body element. */
a:link {
color: #8f8ffc;
}
a:visited {
color: #b67af6;
}
a:active {
color: #fff;
}
img {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div class="mapContent">
<div class="clientList">
<ul>
<!--
Use this as a template. Each list item must be in this format:
<li>
<input type="checkbox">
<img src="..."
alt="..."
data-position-top="..."
data-position-left="...">
Client Name
<div>Client Address</div>
</li>
The only requirement is that there is a checkbox that is followed
by an img sibling, and that img element needs to have a src
attribute, data-position-top attribute (containing the top
coordinate for the location on the map to show this), and
data-position-left attribute (containing the left coordinate for
the location on the map to show this). The alt attribute is
recommended but not required.
-->
<li>
<input type="checkbox">
<img alt=""
src="client1.png"
data-position-top="500px" data-position-left="500px">
Client 1
<div>Address 1</div>
</li>
<li>
<input type="checkbox">
<img alt=""
src="client2.png"
data-position-top="300px" data-position-left="250px">
Client 2
<div>Address 2</div>
</li>
</ul>
</div><!-- clientList -->
</div><!-- mapContent -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
(function () {
/**
* Given an image, create a copy and position it on the map using the
* data-position-top and data-position-left attributes of the image.
* This will insert the new image immediately after the one passed in
* but because it's absolutely positioned will appear on the map.
*/
function showOnMap($img) {
$('<img>', {
src: $img.attr('src'),
alt: $img.attr('alt')
}).css({
'position': 'absolute',
'top': $img.data('position-top'),
'left': $img.data('position-left')
}).insertAfter($img);
}
/**
* Given an image, remove the next sibling image (which was created in
* the showOnMap function) from the DOM.
*/
function hideFromMap($img) {
$img.next('img').remove();
}
/* Attach a click handler to the clientList container that will trigger
* for each checkbox element within the clientList. */
$('.clientList').on('click', 'input[type="checkbox"]', function () {
// this = the checkbox
var $img = $(this).next('img');
if (this.checked) {
showOnMap($img);
}
else {
hideFromMap($img);
}
})
})();
</script>
</body>
</html>
$('.mapContent').on('click', function (event) {
console.log("[" + event.offsetX + ", " + event.offsetY + "]");
});
You cannot mix proper positioning inside tables.Thank you, swa66, because that is something I needed to know.
<script>
.row {
white-space: nowrap;
line-height: 0;
}
</script> <div class="row"><nobr>
<img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"/>
</nobr>
</div>
<div class="row"><nobr>
<img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"/>
</nobr>
</div>
<div class="row"><nobr>
<img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"/>
</nobr>
</div> <div>
<table>
<tr>
<td>
<div class="row"><nobr>
<img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"/>
</nobr>
</div>
<div class="row"><nobr>
<img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"/>
</nobr>
</div>
<div class="row"><nobr>
<img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"
/><img src="blank.png"/>
</nobr>
</div>
</td>
</tr>
</table>
</div> I've tested the code above and it's not suitable for me because the client list column is not within a separate DIV or table, and it scrolls along with the map image