How to display image horizontally in scroll bar? - html

How to display image horizontally in scroll bar? I tried but i am getting output vertically in scroll.Please help me
<div style="width: 1000px; height: 500px; overflow-x:scroll; padding: 5px; display:inline-block; float:left;" >
<div id="slider4" class="text-center">
<div class="slide-img">
<img src="img/team/team1.png">
<p style="font-weight: bold;">B Madhuprasad</p>
<p>Chairman,</p>
<p>Non-Executive</p>
</div>
<div class="slide-img">
<img src="img/team/team2.png">
<p style="font-weight: bold;">Vineet Suchanti</p>
<p>Managing </p>
<p>Director</p>
</div>
<div class="slide-img">
<img src="img/team/team3.png">
<p style="font-weight: bold;">Uday Patil</p>
<p>Director,</p>
<p>ECM</p>
</div>
<div class="slide-img">
<img src="img/team/team4.png">
<p style="font-weight: bold;">Rakesh Choudhari</p>
<p>Managing Director, </p>
<p>Stock Broking</p>
</div>
<div class="slide-img">
<img src="img/team/team5.png">
<p style="font-weight: bold;">Radha Kirthivasan</p>
<p>Senior Vice President,</p>
<p>EDM</p>
</div>
<div class="slide-img">
<img src="img/team/team6.png">
<p style="font-weight: bold;">Nipun Lodha</p>
<p>Head,</p>
<p>Investment Banking</p>
</div>
<div class="slide-img">
<img src="img/team/team07.png">
<p style="font-weight: bold;">Nilesh Dhruv</p>
<p>Head,</p>
<p>Equity Dealing</p>
</div>
<div class="slide-img">
<img src="img/team/team08.png">
<p style="font-weight: bold;">Jayraj Nair</p>
<p>Head, </p>
<p>Depositories</p>
</div>
<div class="slide-img">
<img src="img/team/team09.png">
<p style="font-weight: bold;">Ankur Mestry</p>
<p>Head, <br/>Mutual Funds & <br/>IPO Distribution</p>
</div>
<div class="slide-img">
<img src="img/team/team10.png">
<p style="font-weight: bold;">Cherian MJ</p>
<p>Vice President, </p>
<p>Keynote ESOP</p>
</div>
</div>
</div>
</div>

Define a width to your wrapper, set the white-space to nowrap and finally overflow-x to scroll. The container of the images won't grow beyond the specified width, and the images will all be displayed inside of it. Once the images are too big for the container, they will be cutoff and you get a scrollbar below the slider.
.wrapper{
width: 500px;
overflow-x:scroll;
white-space: nowrap;
}
Fiddle : http://jsfiddle.net/a9zq2Ly2/

try to refer some sources from web
http://www.websitecodetutorials.com/code/photo-galleries/css-horizontal-scroller.php
http://www.wickham43.net/imageswithascrollbar.php

Try this html:
<div class="wrapper">
<div id="slider4" class="text-center">
<div class="slide-img">
<p>1</p>
</div>
<div class="slide-img">
<p>2</p>
</div>
<div class="slide-img">
<p>3</p>
</div>
<div class="slide-img">
<p>4</p>
</div>
<div class="slide-img">
<p>5</p>
</div>
<div class="slide-img">
<p>6</p>
</div>
<div class="slide-img">
<p>7</p>
</div>
<div class="slide-img">
<p>8</p>
</div>
<div class="slide-img">
<p>9</p>
</div>
<div class="slide-img">
<p>10</p>
</div>
<div class="slide-img">
<p>11</p>
</div>
<div class="slide-img">
<p>12</p>
</div>
<div class="slide-img">
<p>13</p>
</div>
<div class="slide-img">
<p>14</p>
</div>
<div class="slide-img">
<p>15</p>
</div>
</div>
</div>
css:
.wrapper{
width: 1000px;
height: 500px;
}
#slider4{
white-space: nowrap;
}
.slide-img{
background: #ccc;
height: 200px;
display: inline-block;
width: 100px;
}
JSFiddle demo

Related

How do I place these div's next to each other to create a 3x2 layout

How do place these div's next to each other in a 3x2 row instead of rows of 1.
Should I make the event-box and event-info as one div instead of two separate div's? I've tried to combine them as one div and given the <p> the event-info class but that didn't work out. I've also tried different sizes for both of the div's and the container to maybe push them next to each other, but that also didn't work. See my code below.
.event-box{
height: 5rem;
width: 30rem;
float: left;
clear: both;
padding: 0;
margin-top: 1rem;
text-align: center;
background: url(/assets/images/placeholderimg4.jpg);}
.event-info{
height: 5rem;
width: 30rem;
float: left;
clear: both;
padding: 0;
margin: 0;
text-align: center;
background-color: rgba(77, 75, 75, 0.1);}
.container{
height: 100%;
width: 64rem;
word-wrap: break-word;
overflow-y: hidden;
padding: 0;}
<div class="container">
<div class="event-box">
<h3 class="event-text">Event 1</h3>
</div>
<div class="event-info">
<p>1</p>
</div>
<div class="event-box">
<h3 class="event-text">Event 2</h3>
</div>
<div class="event-info">
<p>2</p>
</div>
<div class="event-box">
<h3 class="event-text">Event 3</h3>
</div>
<div class="event-info">
<p>3</p>
</div>
<div class="event-box">
<h3 class="event-text">Event 4</h3>
</div>
<div class="event-info">
<p>4</p>
</div>
<div class="event-box">
<h3 class="event-text">Event 5</h3>
</div>
<div class="event-info">
<p>5</p>
</div>
<div class="event-box">
<h3 class="event-text">Event 6</h3>
</div>
<div class="event-info">
<p>6</p>
</div>
</div>
So I used CSS grid for this.
I did combine your event-info and event-box div's together to make them one object in the grid.
.event-box {
height: 5rem;
width: 30rem;
float: left;
clear: both;
padding: 0;
margin-top: 1rem;
text-align: center;
background: url(/assets/images/placeholderimg4.jpg);
}
.event-info {
height: 5rem;
width: 30rem;
float: left;
clear: both;
padding: 0;
margin: 0;
text-align: center;
background-color: rgba(77, 75, 75, 0.1);
}
.container {
height: 100%;
width: 64rem;
word-wrap: break-word;
padding: 0;
display: grid;
grid-template-columns: auto auto auto;
grid-template-rows: auto auto;
grid-gap: 2rem;
}
<div class="container">
<div class="event-box">
<h3 class="event-text">Event 1</h3>
<div class="event-info">
<p>1</p>
</div>
</div>
<div class="event-box">
<h3 class="event-text">Event 2</h3>
<div class="event-info">
<p>2</p>
</div>
</div>
<div class="event-box">
<h3 class="event-text">Event 3</h3>
<div class="event-info">
<p>3</p>
</div>
</div>
<div class="event-box">
<h3 class="event-text">Event 4</h3>
<div class="event-info">
<p>4</p>
</div>
</div>
<div class="event-box">
<h3 class="event-text">Event 5</h3>
<div class="event-info">
<p>5</p>
</div>
</div>
<div class="event-box">
<h3 class="event-text">Event 6</h3>
<div class="event-info">
<p>6</p>
</div>
</div>
</div>
So in the container class I added a display of grid (to use grid functions) and then I added grid-template-columns (which allows you to specify how many columns you want to include) and a grid-template-rows to do the same thing for the rows. I then added a grid-gap to separate the div tags a bit but this value can be played with depending on the desired gap.
You can add a wrap div, like 'event' for it :
<div class="container">
<div class='event'>
<div class="event-box">
<h3 class="event-text">Event 1</h3>
</div>
<div class="event-info">
<p>1</p>
</div>
</div>
<div class='event'>
<div class="event-box">
<h3 class="event-text">Event 2</h3>
</div>
<div class="event-info">
<p>2</p>
</div>
</div>
<div class='event'>
<div class="event-box">
<h3 class="event-text">Event 3</h3>
</div>
<div class="event-info">
<p>3</p>
</div>
</div>
<div class='event'>
<div class="event-box">
<h3 class="event-text">Event 4</h3>
</div>
<div class="event-info">
<p>4</p>
</div>
</div>
<div class='event'>
<div class="event-box">
<h3 class="event-text">Event 5</h3>
</div>
<div class="event-info">
<p>5</p>
</div>
</div>
<div class='event'>
<div class="event-box">
<h3 class="event-text">Event 6</h3>
</div>
<div class="event-info">
<p>6</p>
</div>
</div>
</div>
And a little css addition:
.event{
display:inline-block;
width:49%;
}
Try it - https://jsfiddle.net/5vz3Lhwc/
You can make use of the power of Flexbox! Wrap each row in a div with class row and each column in a div with class col. Example:
<div class="container">
<div class="row">
<div class="col">
<div class="event-box">
<h3 class="event-text">Event 1</h3>
</div>
<div class="event-info">
<p>1</p>
</div>
</div>
<div class="col">
<div class="event-box">
<h3 class="event-text">Event 2</h3>
</div>
<div class="event-info">
<p>2</p>
</div>
</div>
<div class="col">
<div class="event-box">
<h3 class="event-text">Event 3</h3>
</div>
<div class="event-info">
<p>3</p>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="event-box">
<h3 class="event-text">Event 4</h3>
</div>
<div class="event-info">
<p>4</p>
</div>
</div>
<div class="col">
<div class="event-box">
<h3 class="event-text">Event 5</h3>
</div>
<div class="event-info">
<p>5</p>
</div>
</div>
<div class="col">
<div class="event-box">
<h3 class="event-text">Event 6</h3>
</div>
<div class="event-info">
<p>6</p>
</div>
</div>
</div>
</div>
The CSS for the added elements:
.row {
width: 100%;
display: flex;
}
.col {
width: 33%;
flex: 1;
}
Edit: CSS Grid might be an even easier solution.

I want to show lists under sidebar div

I'm coding a project listing page in bootstrap and I'm stuck with an issue.I have a sidebar with a fixed height where I list the checkboxes and I have a main container beside the sidebar which lists the product. By default the area under the sidebar is empty. default style
Is there anyway I can list the products under the sidebar as shown in this
I want to show lists under sidebar and all the items should be in a single row
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css');
aside {
background: #ddd;
}
.row {
align-items: flex-start;
}
.col-sm-4 {
padding-bottom: 25px;
}
img{
max-width: 100%;
}
ul {
list-style: none;
padding-left: 5px;
}
<div class="container">
<div class="row">
<aside class="col-sm-3">
<ul>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
</ul>
</aside>
<main class="col-sm-9">
<div class="row">
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
</div>
</main>
</div>
</div>
see code below (here is fiddle:https://jsfiddle.net/7q9hkrcb/)
#import url('//stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css');
aside {
background: #ddd;
}
body{
margin-top:20px
}
.row {
align-items: flex-start;
}
.col-sm-6 {
padding-bottom: 25px;
}
.col-sm-4 {
padding-bottom: 25px;
}
img{
max-width: 100%;
}
ul {
list-style: none;
padding-left: 5px;
}
<div class="container">
<div class="row">
<aside class="col-sm-4">
<ul>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
<li>Checkbox</li>
</ul>
</aside>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-6">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-6">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-6">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-6">
<img src="http://via.placeholder.com/150x150">
</div>
</div>
</div>
<div class="col-sm-12">
<div class="row">
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
<div class="col-sm-4">
<img src="http://via.placeholder.com/150x150">
</div>
</div>
</div>
</div>
</div>

<div>'s not appearing in a 'stack'

Sorry if this has been asked, but nothing I found worked in my case.
Here is my current code. I have included more detailed problems there, but basically some of my elements are either not appearing or appearing in unwanted locations.
https://jsfiddle.net/9e8tffh5/2/
<div class="chat">
<div class="bar">
<div class="title">
<span class="name">Random Chat</span>
</div>
</div>
<div class="options">
</div>
<div class="room">
<div class="post other" id="1">
<div class="content">
<span class="note">Hi there!</span>
</div>
<div class="details">
<div class="poster">
<span class="name">Bob</span>
</div>
<div class="time">
<span class="time">9:32</span>
</div>
</div>
</div>
<div class="post self" id="2">
<div class="content">
<span class="note">Hi Bob</span>
</div>
<div class="details">
<div class="time">
<span class="time">12:32</span>
</div>
</div>
</div>
<div class="post self" id="3">
<div class="content">
<span class="note">How are you doing?</span>
</div>
<div class="details">
<div class="time">
<span class="time">9:33</span>
</div>
</div>
</div>
<div class="post other" id="4">
<div class="content">
<span class="note">Great!</span>
</div>
<div class="details">
<div class="poster">
<span class="name">Bob</span>
</div>
<div class="time">
<span class="time">9:32</span>
</div>
</div>
</div>
</div>
<div class="message">
<div class="input">
<input type="text" placeholder="Send a message" />
</div>
</div>
</div>
fiddle
.chat .room .self {
/* position: absolute;
right: 8px; */
text-align: right;
}
.chat .room .self .details {
/* position: absolute;
right: 8px; */
text-align: right;
}

How do I center align a div's content with content elements floated towards the left?

I'm trying to build a simple image gallery where the gallery items are placed in a div. But since the items are floated left, they don't center align overall when I add text-align: center; to the parent div. (I'm using Bootstrap 3 and parent div is panel-body. The contents lie in panel-body.)
CSS:
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<style type="text/css" media="screen">
.image-box {
float: left;
}
.image-box img {
width: 128px;
height: 128px;
}
</style>
HTML:
<div class="panel panel-default">
<div class="panel-heading text-center">
<h3 class="panel-title">GALLERY</h3>
</div>
<div class="panel-body">
<div class="image-box">
<img src="member-icon.png">
<P class="caption">Image Description</P>
</div>
<div class="image-box">
<img src="member-icon.png">
<P class="caption">Image Description</P>
</div>
<div class="image-box">
<img src="member-icon.png">
<P class="caption">Image Description</P>
</div>
</div>
</div>
text-align: center; will not work when use floating. use inline block.
Please see code below
.panel-body {
text-align: center;
}
.image-box {
display: inline-block;
margin-left: -4px;
}
.image-box img {
width: 128px;
height: 128px;
}
<div class="panel panel-default">
<div class="panel-heading text-center">
<h3 class="panel-title">GALLERY</h3>
</div>
<div class="panel-body">
<div class="image-box">
<img src="http://placehold.it/300x300">
<P class="caption">Image Description</P>
</div>
<div class="image-box">
<img src="http://placehold.it/300x300">
<P class="caption">Image Description</P>
</div>
<div class="image-box">
<img src="http://placehold.it/300x300">
<P class="caption">Image Description</P>
</div>
</div>
</div>
Here is a live demo
HTML file:
<div class="panel panel-default">
<div class="panel-heading text-center">
<h3 class="panel-title">GALLERY</h3>
</div>
<div class="panel-body">
<div class="col-md-offset-4 col-xs-offset-3">
<div class="image-box">
<img src="member-icon.png">
<p class="caption">Image Description</p>
</div>
<div class="image-box">
<img src="member-icon.png">
<p class="caption">Image Description</p>
</div>
<div class="image-box">
<img src="member-icon.png">
<p class="caption">Image Description</p>
</div>
</div>
</div>
</div>
CSS file:
.image-box {
float: left;
}
.image-box img {
width: 128px;
height: 128px;
padding:15px;
}
See Demo: Div content center in panel body

How to make the grid system centered horizontally?

I want to get the grid system to center but it won't, i was thinking maybe it has something to do with my pictures' border?. here's the screen shotwhat it is right now
what i want it to be
HTML:
<div class=" container">
<div class="row">
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
</div>
</div>
CSS:
.optionBorder
{
border: 1px solid #f5f5f5;
height: 130px;
width: 130px;
line-height: 130px;
text-align: center;
}
Take another element before row with some width and make them center
for example.:
HTML
<div class="test">
<div class="row">
<div class="col-md-4">
<div class="optionBorder">
<img src="http://placehold.it/350x150" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="http://placehold.it/350x150" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="http://placehold.it/350x150" height="74px" width="50px">
</div>
</div>
</div>
</div>
CSS
.test {
width: 450px;
margin: auto;
margin-bottom: 15px;
}
bootply
<style>
.paraentCont{
width:100%;
max-width:300px;
margin:auto;
}
</style>
<div class=" container">
<div class="paraentCont">
<div class="row">
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
</div>
Give to .row fixed width such as 700px, and margin-left/right auto
look at this example http://www.bootply.com/GFDHc6p5tg
Actually here is there right way to go while using Bootsrap
Use the predefine class text-center
Use q Bootstrap helper like .inline-block{display: inline-block}
.inline-block{display: inline-block}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class=" container">
<div class="row text-center">
<div class="col-md-4 inline-block">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4 inline-block">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4 inline-block">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
</div>
</div>