Want to create a slider containing 3 image containers and need all of them in the same row. All image containers are same size, but the size of slider is around 2.5 images, so the third one should overflow instead of going to new row. Example:
How it should look
What i have for now
html
<div class="image-slide-wrapper">
<div class="images-section">
<div class="image-slide">
<div class="slide-img">
</div>
</div>
<div class="image-slide">
<div class="slide-img">
</div>
</div>
<div class="image-slide">
<div class="slide-img">
</div>
</div>
</div>
</div>
scss
.image-slide-wrapper {
float: left;
height: 55%;
width: 100%;
.images-section {
float: left;
height: 85%;
width: 100%;
border: 1px solid grey;
border-radius: 8px;
overflow: hidden;
padding: 0.125rem;
}
.image-slide {
float: left;
height: 100%;
width: 100px;
margin-right: 0.25rem;
.slide-img {
float: left;
height: 100%;
width: 100%;
border-radius: 0.35rem;
background-color: #e9e9e9;
in the text slider is images-section class and image container is image-slide class. Forgot to mention that I have to go with float to make consistent with the rest of the code.
<div style="overflow: hidden; width: 250px;">
<div style="width: max-content">
<img style="width: 100px;height: 100px;border: 1px solid black;" src="...">
<img style="width: 100px;height: 100px;border: 1px solid black;" src="...">
<img style="width: 100px;height: 100px;border: 1px solid black;" src="...">
</div>
</div>
You could remove float from the thumb elements and use display: flex and flex-flow: row nowrap on the container
.container {
height: 100px;
width: 250px;
border: 1px solid grey;
border-radius: 8px;
overflow: hidden;
padding: 0.125rem;
display: flex;
flex-flow: row nowrap;
}
.image-slide {
height: calc(100% - .25rem);
flex: 1 0 100px;
margin-right: 0.25rem;
border: 1px #ccc solid;
}
<div class="container">
<div class="image-slide"></div>
<div class="image-slide"></div>
<div class="image-slide"></div>
<div class="image-slide"></div>
</div>
This works. You can add display:flex; and flex-wrap:nowrap; to .image-slide-wrapper class.
.main {
float: left;
height: 85%;
width: 100%;
border: 1px solid grey;
border-radius: 8px;
overflow: hidden;
padding: 0.125rem;
display:flex;
flex-wrap:nowrap;
}
.slider {
float: left;
height: 100%;
width: 300px;
margin-right: 0.25rem;
display: block;
}
<div class="main">
<div class="slider">
<img class="img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTBYCs940TLL3tx_nyn7fVeidXWZyfOKV5QrQ&usqp=CAU">
</div>
<div class="slider">
<img class="img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTBYCs940TLL3tx_nyn7fVeidXWZyfOKV5QrQ&usqp=CAU">
</div>
<div class="slider">
<img class="img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTBYCs940TLL3tx_nyn7fVeidXWZyfOKV5QrQ&usqp=CAU">
</div>
</div>
Related
Does anyone know how to remove the thin gap to the left of the scrollbar that is letting the background through (showing green on this example)?
.menu {
min-width: 195px;
max-height: 200px;
overflow: auto;
position: fixed;
background-color: #F9F9F9;
border: solid 1pt yellow;
}
.button {
border: solid 1px white;
min-width: 200px;
}
body {
background-color: green;
}
<div id="x" class="menu" style="top: 100px; left: 100px;">
<div class="button">a</div>
<div class="button">b</div>
<div class="button">c</div>
<div class="button">d</div>
<div class="button">e</div>
<div class="button">f</div>
<div class="button">g</div>
<div class="button">h</div>
<div class="button">i</div>
<div class="button">j</div>
<div class="button">k</div>
<div class="button">l</div>
<div class="button">m</div>
<div class="button">n</div>
<div class="button">o</div>
<div class="button">p</div>
A running example of this can be found on https://jsfiddle.net/Abeeee/f9jtsrw0/29/
It seems like a bug to me but I replaced:
border: solid 1pt yellow;
from your .menu with:
border: solid 1px yellow;
The pt seems to make rounding errors occur.
I've added border-right: 0pt; to the menu css which removes the right border.
.menu {
width: 200px;
height: 195px;
overflow-y: scroll;
overflow-x: hidden;
position: fixed;
background-color: #F9F9F9;
border: solid 1pt yellow;
border-right: 0pt;
}
.button {
border: solid 1px white;
width: 200px;
}
body {
background-color: green;
}
.background {
background-color: white;
z-index: -1;
}
<div id="x" class="menu" style="top: 100px; left: 100px;">
<div class="background">
<div class="button">a</div>
<div class="button">b</div>
<div class="button">c</div>
<div class="button">d</div>
<div class="button">e</div>
<div class="button">f</div>
<div class="button">g</div>
<div class="button">h</div>
<div class="button">i</div>
<div class="button">j</div>
<div class="button">k</div>
<div class="button">l</div>
<div class="button">m</div>
<div class="button">n</div>
<div class="button">o</div>
<div class="button">p</div>
</div>
</div>
I'm trying to replicate the azure portal design layout. The challenge that I'm facing, is once I'm inside of a component (in the image example "Virtual Machine") I need to ability to create a new component inside of it, but have the style appear that its a new panel in the main panel collection. Any ideas? I've provided a template pen below.
Codepen Link
<section id="panel-container">
<div class="panel" style="border:1px solid red;"></div>
<div class="panel" style="border:1px solid red;">
<div class="sub-panel" style="border:4px solid cyan;"></div>
</div>
</section>
you can use a mix of flexbox and position
*,
*::before,
*::after {
box-sizing: border-box
}
body {
margin: 0
}
#panel-container {
overflow-x: hidden;
height: 100vh;
border: 1px solid black;
display: flex;
}
.panel {
flex: 0 450px;
height: 100vh;
display: flex;
border: 1px solid red;
position: relative;
}
.sub-panel {
position: absolute;
top: 0;
left: 450px;
width: 450px;
height: 100vh;
border: 4px solid cyan;
}
<section id="panel-container">
<div class="panel"></div>
<div class="panel">
<div class="sub-panel"></div>
</div>
</section>
you should use display: inline-flex instead of display: inline-block.
#panel-container {
overflow: scroll;
overflow-y: hidden;
white-space: nowrap;
height: 100vh;
border: 1px solid black;
}
.panel {
position: relative;
display: inline-flex;
width: 250px;
height: 100vh;
}
.sub-panel {
width: 250px;
height: 100vh;
}
<section id="panel-container">
<div class="panel" style="border:1px solid red;"></div>
<div class="panel" style="border:1px solid red;">
<div class="sub-panel" style="border:4px solid cyan;"></div>
</div>
</section>
Unless somebody can provide an alternative solution, this table hack is the best I can come up with. Codepen Link
<table>
<tr>
<td>Panel</td>
<td>Panel
<td style="width: 600px;background:red;">Sub Panel</td>
<td>Sub Sub Panel</td>
</td>
<td>Panel</td>
</tr>
</table>
CSS
table {
border-collapse: collapse;
border-spacing: 0;
}
td {
min-width: 300px;
height:100vh;
padding: 15px;
vertical-align: top;
border: 1px solid black;
}
I can't seem to get the two images of class 'social' side-by-side, central to the column of class 'col-sm-4'. Instead they stack as the screen size decreases. Any ideas how I can do this responsively?
HTML
<div class="container-fluid">
<div class="row" style="border-top: 0">
<!-- Profile info -->
<div class="col-sm-4 col-sm-offset-4">
<img class="img-circle img-responsive" src="images/callum.jpg">
<h1 class="text-center" style="color: #3FA2B2">Callum Messiter</h1>
<p class="text-center">100-trillion cells and 100-billion neurons defying the 1 in 10<sup>2,685,000</sup> chance of me existing.</p>
<img class="social" src="images/twitter.png">
<img class="social" src="images/github.png">
</div>
</div>
</div>
CSS
.row{
border-top: 1px solid #808080;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
}
.col-sm-4{
height: 450px;
}
.img-circle{
height: 200px;
width: 200px;
margin: 0 auto;
position: relative;
top: 40px;
border: 2px solid white;
}
.text-center{
font-family: helvetica;
color: white;
position: relative;
top: 50px;
}
span{
font-weight: bold;
background-color: #e6e6e6;
color: #3FA2B2;
padding: 3px 7px 3px 7px;
}
.social{
height: 50px;
width: 50px;
margin: 0 auto;
}
Add class text-center before img. like this
<div class="text-center">
<img class="social" src="https://files.allaboutbirds.net/wp-content/themes/html5blank-stable/images/blue-winged-warbler.jpg">
<img class="social" src="https://files.allaboutbirds.net/wp-content/themes/html5blank-stable/images/blue-winged-warbler.jpg">
</div>
DEMO HERE https://jsfiddle.net/ff9g43t8/
Try:
.social {
display: inline-block;
}
I've seen an article about vertical centering of text and image. I've seen an article about vertical centering text inside a floated div.
But not both conditions.
Here's my experiment:
.phase {
width: 500px;
height: 500px;
border: 1px solid red;
}
.float-right {
float: right;
}
.carousel {
height: 300px;
display: table-cell;
vertical-align: middle;
border: 1px solid orange;
}
.circle {
float: left;
height: 50px;
width: 50px;
vertical-align: middle;
border: 1px solid green;
border-radius: 50%;
background-color: white;
}
.thumbnail {
float: left;
}
<div class="phase">
<div class="float-right">
<div class="carousel">
<div class="circle">
</div>
<div class="thumbnail">
<img src="https://www.google.com/images/nav_logo231.png" style="width:160px;height:160px;vertical-align:middle" />
</div>
</div>
</div>
<h1>I love css</h1>
</div>
Notice the image is vertically centered, but the green circle is not vertically centered.
How can I get both the image and the green circle vertically centered?
You can achieve a totally centered element using calc and view-units:
#example {
width: 100px;
height: 100px;
border: 1px solid green;
border-radius: 50px;
position: fixed;
top: calc(50vh - 50px);
left: calc(50vw - 50px);
}
<div id="example"></div>
This example will keep it right in the centre even with scrolling, etc - but you could place it centre based on the initial view using an absolute position.
My fixed code. It works in IE and in Chrome.
top: calc(0.5vh + 50px); is what does the trick. 50px of course would be the height of the element you want to vertically center.
.phase {
width: 500px;
height: 500px;
border: 1px solid red;
}
.float-right {
float: right;
}
.carousel {
height: 300px;
display: table-cell;
vertical-align: middle;
border: 1px solid orange;
}
.circle {
position: relative;
float: left;
top: calc(0.5vh + 50px);
height: 50px;
width: 50px;
vertical-align: middle;
border: 1px solid green;
border-radius: 50%;
background-color: white;
}
.thumbnail {
float: left;
border: 1px solid black;
}
<div class="phase">
<div class="float-right">
<div class="carousel">
<div class="circle">
</div>
<div class="thumbnail">
<img src="https://www.google.com/images/nav_logo231.png" style="width:160px;height:160px;" />
</div>
</div>
</div>
<h1>I love css</h1>
</div>
You need to place the circle in a container and set the container's line-height property. Try this:
.phase {
width: 500px;
border: 1px solid red;
}
.float-right {
float: right;
}
.carousel {
height: 300px;
display: table-cell;
vertical-align: middle;
border: 1px solid orange;
}
.container {
float: left;
height: 300px;
line-height: 300px;
}
.circle {
display: inline-block;
height: 50px;
width: 50px;
border: 1px solid green;
border-radius: 50%;
background-color: white;
}
.thumbnail {
display: inline-block;
}
<div class="phase">
<div class="float-right">
<div class="carousel">
<div class="container"><div class="circle">
</div></div>
<div class="container"><div class="thumbnail">
<img src="https://www.google.com/images/nav_logo231.png" style="width:160px;height:160px;vertical-align:middle" />
</div></div>
</div>
</div>
</div>
below is my code, the thumb Divs are starting from left but how can I make them centralized?
.thumbsPanel {
border: thin black dashed;
width: 800px;
height: 500px;
margin: 0 auto;
}
.thumbs {
float: left;
width: 100px;
height: 100px;
border: 0;
margin: 0 1em 1em 0;
}
<div class="thumbsPanel">
<div class="thumbs"><img src="1.jpg"></div>
<div class="thumbs"><img src="2.jpg"></div>
<div class="thumbs"><img src="3.jpg"></div>
</div>
There's not much point in floating the divs if you want to center them. Instead make them inline-block elements and use text-align:center on the parent:
.thumbsPanel {
border: thin black dashed;
width: 800px;
height: 500px;
margin: 0 auto;
text-align: center;
}
.thumbs {
display: inline-block;
width: 100px;
height: 100px;
border: 0;
margin: 0 1em 1em 0;
}
<div class="thumbsPanel">
<div class="thumbs">
<a href="1.html">
<img src="1.jpg">
</a>
</div>
<div class="thumbs">
<a href="2.html">
<img src="2.jpg">
</a>
</div>
<div class="thumbs">
<a href="3.html">
<img src="3.jpg">
</a>
</div>
</div>
My favorite method is to add a text-align: center; to the parent element, then use display: inline-block; instead of float: left;
.thumbsPanel {
border: thin black dashed;
width: 800px;
height: 500px;
margin: 0 auto;
text-align: center;
}
.thumbs {
display: inline-block;
width: 100px;
height: 100px;
border: 0;
margin: 0 1em 1em 0;
}
<div class="thumbsPanel">
<div class="thumbs"><img src="1.jpg"></div>
<div class="thumbs"><img src="2.jpg"></div>
<div class="thumbs"><img src="3.jpg"></div>
</div>
You can use inline-block to thumbs instead of float left like:
.thumbsPanel {
border: thin black dashed;
width: 800px;
height: 500px;
margin: 0 auto;
text-align: center;
}
.thumbs {
display: inline-block;
border:1px solid #000;
width: 100px;
height: 100px;
margin: 0 1em 1em 0;
}
<div class="thumbsPanel">
<div class="thumbs">a</div>
<div class="thumbs">b</div>
<div class="thumbs">c</div>
</div>
If you want to conserve your floating behavior you should add an container to your thumbs, also using float dont forget to clearfix the container like:
.thumbsPanel {
border: thin black dashed;
width: 800px;
height: 500px;
margin: 0 auto;
text-align: center;
}
.thumbsWrap {
display: inline-block;
overflow: hidden;
}
.thumbs {
float: left;
width: 100px;
height: 100px;
border: 1px solid #000;
margin: 0 1em 1em 0;
}
<div class="thumbsPanel">
<div class="thumbsWrap">
<div class="thumbs">a</div>
<div class="thumbs">b</div>
<div class="thumbs">c</div>
</div>
</div>