Horizontal scroll bar for thumbnails - html

I'm having a thumbnail with imgs in divs, so when a img press its shows big in the same window.
I wish to scroll horizonal to see them, instead of vertical as the default.
I mannaged to hide the y scroll bar using:
overflow-x: auto;
-ms-overflow-x: auto;
overflow-y: hidden;
-ms-overflow-y: hidden;
now how do i make the imges run out of horizonal limit rather then vertical limit.
my pics are serrunded by:
<div class='item'>
<img src='picaddress.jpg' alt='picDescription' />
<p>'picDescription'</p>
additonal code:
<div id="imagegallery">
<div id="items">
<div class='item'>
<img src="images/img1.jpg" alt="Test Image">
<p>'Test Image'</p>
</div>
<div class='item'>
<img src="images/img2.jpg" alt="Test Image">
<p>'Test Image'</p>
</div>
<div class='item'>
<img src="images/img3.jpg" alt="Test Image">
<p>'Test Image'</p>
</div>
<div class='item'>
<img src="images/img4.jpg" alt="Test Image">
<p>'Test Image'</p>
</div>
<div class='item'>
<img src="images/img5.jpg" alt="Test Image">
<p>'Test Image'</p>
</div>
</div>
</div>
</div>
CSS:
#imagegallery{
background:#F2F2F2;
padding:10px 10px 10px 10px;
}
#imagegallery #items{
width: 100%;
border: 1px solid #DFDFDF;
background:white;
height: 100px;
overflow: auto;
}
#imagegallery #items .item {
float: left;
padding:5px;
position: relative;
width: 102px;
height:77px;
margin: 10px;
background-color: #fff;
cursor: pointer;
border: 1px solid white;
display: inline;
}
#imagegallery #items .item:hover{
border: 1px solid #ddd;
}
#imagegallery #items .item img {
max-width:100px;
max-height:75px;
width:100px;
}
#imagegallery #items p{
display:none;
}
it's a dynamic page so number of pics changes.

I hope I understand you right and you want to have the images displayed next to each other instead of under each other.
To make that work you could use the float property on the div with class "item", like so:
div.item {
float: left;
width: 100px;
}
Don't forget to clear after the items.
If the width of all the items is bigger then the width of the surrounding div (with overflow-x: scroll) you'll get what you want.
Example created at http://jsfiddle.net/deCube/Ctja7/.

You can use an "ul" in your div and display as manu "li"s in the "ul" as you want on one line. Then to show another line of images below, just repeat the "ul & "li"s
Exmaple:
<div id="images">
<ul>
<li><img src="images/rings/thumbnails/image1.jpg"></li>
<li><img src="images/rings/thumbnails/image2.jpg"></li>
<li><img src="images/rings/thumbnails/image3.jpg"></li>
<li><img src="images/rings/thumbnails/image4.jpg"></li>
<li><img src="images/rings/thumbnails/image5.jpg"></li>
</ul>
</div>
You can then just style the "div", "ul" and "li" with css. See an example page I have here. Each line of images is an "ul" with 5 "li"s in it. You are more than welcome to copy the code if you think it's useful.

Related

Div HTML element is hiding behind an Image

Actually I I created an Image Slider using HTML and CSS. And I wanted to create a popup box. So before adding the functonality I created a layout for it and tried to make it in center. So when I write position:relative; bottom:300px(or whatever)it goes up but hides behind the image Slider.
.popup{
width: 900px;
height: 500px;
background-color: white;
border: 5px solid black;
position: relative;
bottom:0px;
}
<div id="slider">
<figure>
<img src="img3.jpg">
<img src="3.JPG">
<img src="4.JPG">
<img src="img3.jpg">
<img src="9.jpg" alt="">
</figure>
</div>
<center>
<div class="popup">
Dummy Text
</div>
</center>
Use z-index to specify the element you want on top:
https://www.w3schools.com/cssref/pr_pos_z-index.asp
Simply set your position with absolute.
.box .text{
position: absolute;
}
Demo jsFiddle

How to fit image so that there will be no white spaces beside my image?

I am limited to use only html and css for this project. I try extending the width but that leaves me having horizontal scroll and I don't want to do that. I also try using px as a measurement but that doesn't work either.
<img src="img/gallery.jpg" style="width:100%;height:90%;white-space:nowrap">
https://i.stack.imgur.com/wsxrk.png
use width:100% as shown below:
img{
width:100%
}
You need to use object-fit property on your image. Here is a demo:
.container {
width: 500px;
height: 500px;
border: 1px solid #000;
}
.container img {
width: 100%;
height: 100%;
object-fit: cover;
}
<div class="container">
<img src="https://via.placeholder.com/350x150" alt="">
</div>
There are a few known way of removing white spacing. Here are a the best two, IMO:
Set the font size of the parent to be 0px:
div {
background-color: orange;
margin-bottom: 20px;
}
.nows {
font-size: 0px;
}
<div>
<img src="https://via.placeholder.com/150x150">
<img src="https://via.placeholder.com/150x150">
</div>
<div class="nows">
<img src="https://via.placeholder.com/150x150">
<img src="https://via.placeholder.com/150x150">
</div>
Use comments to mitigate the white space in the code
div {
background: orange;
margin-bottom: 20px;
}
<div>
<img src="https://via.placeholder.com/150x150">
<img src="https://via.placeholder.com/150x150">
</div>
<div><!--
--><img src="https://via.placeholder.com/150x150"><!--
--><img src="https://via.placeholder.com/150x150"><!--
--></div>
body {
margin:0px;
padding:0px;
}
I posted the same problem on other forum and this works. Thanks for the help.

2 headers lined up with 2 images side by side

I have the following HTML structure currently:
<div id="image" style="margin: 20px;">
<h5>
<span>DriverName1</span>
<span>DriverName2</span>
</h5>
<img src=/>
<img src= />
</div>
I am trying to make the images appear side by side which they are doing, but the headers for drivername1 and drivername2 are appearing right next to each other over the same image. How do I make these spans match up with the top left edge of each image? I tried adding separate headers over each image but that makes the images go vertically one on top of the other then.
you can consider using display:flex for this
check the following snippet
div{
display:flex;
}
.image {
display: flex;
flex-direction: column;
border:1px solid;
margin-left:10px;
}
img {
width: 100px;
height: 100px;
}
<div id="image" style="margin: 20px;">
<section class="image">
<header>DriverName1</header>
<img src="http://blog.caranddriver.com/wp-content/uploads/2015/11/BMW-2-series.jpg">
</section>
<section class="image">
<header>DriverName2</header>
<img src="http://blog.caranddriver.com/wp-content/uploads/2015/11/BMW-2-series.jpg" width=25px height=25px>
</section>
</div>
Non-flex solution
div * {
display: inline-block;
}
.image {
border: 1px solid;
margin-left: 10px;
}
img {
width: 100px;
height: 100px;
display: table-cell;
}
header {}
<div id="image" style="margin: 20px;">
<section class="image">
<header>DriverName1</header>
<img src="http://blog.caranddriver.com/wp-content/uploads/2015/11/BMW-2-series.jpg">
</section>
<section class="image">
<header>DriverName2</header>
<img src="http://blog.caranddriver.com/wp-content/uploads/2015/11/BMW-2-series.jpg" width=25px height=25px>
</section>
</div>
Hope this helps

How to put image tiles properly without colum gap or row gap in between using only CSS?

I'm new to HTML and CSS. For one of my projects, I need to put 16 images into a 4x4 grid of tiles on a webpage. These tiles cannot have gaps between them, and they need to stretch to fill the browser from side to side. They also should only scroll vertically. We are only allowed to use JavaScript or JQuery so I can only use HTML and CSS.
I wrote 4 div elements, each represents a row; inside each div, a span element holds 4 images - that's how I made the 4x4 grid. A code snippet looks like this:
/* One row in a div*/
<div class="map">
<span>
<img src="map_images/1.png">
<img src="map_images/2.png">
<img src="map_images/3.png">
<img src="map_images/4.png">
</span>
</div>
I also wrote a navigation bar that should float above the background images in the upper right corner:
/* 4 div elements of 4 rows before this code*/
<div id="nav">
<div>Foo</div>
<div>Boo</div>
</div>
For the above code, my stylesheet looks like this:
.map{
margin:0;
padding:0;
}
#nav {
position: absolute;
top: 0;
right: 0;
z-index: 10;
}
However, I've encountered several problems at this point.
First, I still have column gaps and row gaps between all 16 images. No matter what values I set map margin and padding to, nothing changes. I even tried negative values, still nothing changed. Can someone tell me how to go about this problem, eliminating all gaps?
Secondly, I googled and learned that z-index can be used to make div float above background; however, this is no working here and it seems that div #nav stays in the upper right corner as a separate div that does take up space, instead of floating above. Any suggestions on this?
Float left and set the width to 25%. Also I show below how to create a floating menu using the :hover pseudo-class.
.map div img {
width: 25%;
float:left;
display: inline-block;
}
#nav {
width: 50px;
background-color: grey;
}
#nav ul {
margin: 0;
padding: 0;
width: 50px;
background-color: grey;
position: absolute;
display:none;
}
#nav:hover ul, #nav ul:hover {
display:block;
}
<div id="nav">
Menu
<ul>
<li>Foo</li>
<li>Boo</li>
</ul>
</div>
<div class="map">
<div class="row">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
</div>
<div class="row">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
</div>
<div class="row">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
</div>
<div class="row">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
<img src="http://lorempixel.com/100/100/">
</div>
</div>
I think you are looking for something like this? See fiddle http://jsfiddle.net/DIRTY_SMITH/q12bh4se/4/
Snippet :
body {
margin: 0px;
}
div {
width: 50%;
float: left;
}
img {
width: 50%;
float: left;
}
.top-left {
z-index: 9999;
position: absolute;
top: 0;
left: 0;
color: white;
}
.top-right {
z-index: 9999;
position: absolute;
top: 0;
right: 0;
color: white;
}
<h1 class="top-left">Top Left</h1>
<h1 class="top-right">Top Right</h1>
<div class="row-1-col-1">
<img src="http://lorempixel.com/g/200/200/">
<img src="http://lorempixel.com/200/200/sports/">
<img src="http://lorempixel.com/200/200/sports/1/">
<img src="http://lorempixel.com/200/200/sports/Dummy-Text/">
</div>
<div class="row-1-col-2">
<img src="http://lorempixel.com/g/200/200/">
<img src="http://lorempixel.com/200/200/sports/">
<img src="http://lorempixel.com/200/200/sports/1/">
<img src="http://lorempixel.com/200/200/sports/Dummy-Text/">
</div>
<div class="row-2-col-3">
<img src="http://lorempixel.com/g/200/200/">
<img src="http://lorempixel.com/200/200/sports/">
<img src="http://lorempixel.com/200/200/sports/1/">
<img src="http://lorempixel.com/200/200/sports/Dummy-Text/">
</div>
<div class="row-3-col-3">
<img src="http://lorempixel.com/g/200/200/">
<img src="http://lorempixel.com/200/200/sports/">
<img src="http://lorempixel.com/200/200/sports/1/">
<img src="http://lorempixel.com/200/200/sports/Dummy-Text/">
</div>
All I had to do was set float: left and width: 25% on the images in CSS
.map img{
float: left;
width: 25%;
}
DEMO

Display images in a row (HTML)

So I have this very simple HTML page. All I want is to display images in one long row. What is the simplest way, that would work on all browsers?
<html>
<head>
<title>My title</title>
</head>
<body>
<div id="images">
<img src="1.jpg">
<img src="2.jpg">
<img src="3.jpg">
<img src="4.jpg">
<img src="5.jpg">
<img src="6.jpg">
</div>
</body>
</html>
If you want #images to be a single row, you can turn off word wrapping.
#images {
white-space: nowrap;
}
JSFiddle
Look this jsbin
I think this is the simplest way:
HTML:
<ul>
<li><img src="1.jpg"></li>
<li><img src="2.jpg"></li>
<li><img src="3.jpg"></li>
<li><img src="4.jpg"></li>
<li><img src="5.jpg"></li>
<li><img src="6.jpg"></li>
</ul>
CSS:
ul {
white-space: nowrap;
}
ul, li {
list-style: none;
display: inline;
}
Updated: For no wrap!
Make your container div wide enough to handle all of your images.
Let's say all your images are 300px by 300px;. if you have 6 images, your div would be 1800px wide
Just make the container div wide enough to accommodate all of your images and they won't wrap. Then float each image left.
<style>
#images {
width: 1800px;
height: 300px;
}
#images img {
float: left;
}
</style>
I'm suspecting somebody with much more CSS knowledge will have a better way?...
With bootstrap:
<div class="row">
<div class="column">
<img src="1.jpg">
</div>
<div class="column">
<img src="2.jpg">
</div>
...
</div>
See How To Place Images Side by Side
Here's a Fiddle
#images {
width: 2000px; /* Increase if needed */
}
#images img {
width: 300px;
height: 200px;
float: left;
}