I am trying to get my main area container (with overflow: auto) to scroll, but with no extra scroll bar. Currently there is an extra scroll bar for the container. I would like to use to main scroll bar to scroll up and down. Im sure ill have to do a slightly different layout to get this to work. I would prefer a flexbox solution, however am open to any method.
https://codepen.io/marti2221/pen/oyxZzx
<section id="container" >
<header id="header" >
<div class="header-top">
<button class="order-btn">Order</button>
<div class="icon-1">
<div class="">icon 1</div>
<div class="">icon 2</div>
</div>
</div>
<div class="header-bottom">
</header>
<article id="content" >
<div class="main-bg">
<div class="menu-box">
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
</div>
</div>
</article>
</section>
html, body {
height: 100%;
width: 100%;
}
#container {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
background-color: lightblue;
}
#container header {
background-color: gray;
height: 200px;
display: flex;
flex-direction: column;
}
.header-top {
display: flex;
justify-content: space-between;
}
.order-btn {
align-self: flex-start;
}
#container article {
flex: 1 1 auto;
overflow-y: auto;
min-height: 0px;
}
.main-bg {
display: flex;
justify-content: center;
}
.menu-box {
width: 35%;
border: 1px solid black;
display: flex;
flex-direction: column;
}
.top-info-wrapper {
display: flex;
justify-content: space-between;
}
.icon-1 {
display: flex;
}
.header-bottom {
display: flex;
width: 35%;
}
Removed flex from container div as it was not required. Also moved background-color: lightblue; to article instead of container div. Also added margin: 0; on body tag.
html, body {
height: 100%;
width: 100%;
margin: 0;
}
#container {
height: 100%;
width: 100%;
}
#container header {
background-color: gray;
height: 100px;
position: fixed;
top: 0;
width: 100%;
}
.header-top {
display: flex;
justify-content: space-between;
}
.order-btn {
align-self: flex-start;
}
#container article {
background-color: lightblue;
overflow-y: auto;
min-height: 0px;
margin-top: 100px;
}
.main-bg {
display: flex;
justify-content: center;
}
.menu-box {
width: 35%;
border: 1px solid black;
display: flex;
flex-direction: column;
}
.top-info-wrapper {
display: flex;
justify-content: space-between;
}
.icon-1 {
display: flex;
}
.header-bottom {
display: flex;
width: 35%;
}
<section id="container" >
<header id="header" >
<div class="header-top">
<button class="order-btn">Order</button>
<div class="icon-1">
<div class="">icon 1</div>
<div class="">icon 2</div>
</div>
</div>
<div class="header-bottom">
</header>
<article id="content" >
<div class="main-bg">
<div class="menu-box">
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
<div class="menu-item">
<div class="top-info-wrapper">
<h3>Name</h3>
<h3>$6.50</h3>
</div>
<div class="descr-wrapper">
<p>this is a paragraph about a menu-item. It should be a few sentances long and take up only space in the box</p>
</div>
</div>
</div>
</div>
</article>
</section>
Related
I made a product slider using Html Css JS and I want the scrollby left and right goes smoth instead of going directly.
Here is my website it works fine on the first slider but the second slider and third that have this issue
Html
<!-- Container for the layout of the full carousel -->
<div class="container2 cover2">
<div class=" scrolling-wrapper scrollmenu-SLIDER2 scroll-images2">
<div class="card2">
<a href=" https://ma.santemagasin.com/produit/hemoconfort/">
<div class="card-img2">
<img src=" https://ma.santemagasin.com/wp-content/uploads/2022/10/hemo-confort-compr.webp">
<h5 class="Product-Disc"> مكمل طبيعي لراحة البواسير
علاج مضمون من المصدر للبواسير الداخلية
حل نهائي للنزيف والالم</h5>
<p class="Product-Prix"> 249د.م.
</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/iron-hair/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/iron-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي خاص بالرجال
sante magasinمن
حل لتساقط الشعر
ملء فراغات اللحية
60 كبسولة نباتية
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/vitex/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/vtx-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي من كف مريم
للنساء ٬ الدورة الشهرية
الحمل ٬ 60 كبسولة نباتية
صنع مغربي٬ 300 ملغرام
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/perfecto/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/prfrcto-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي
لزيادة المناطق الأنثوية
بدون أضرار جانبية
مستخلصات طبيعية
60 كبسولة٬ 300 ملغرام
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/hair-lit/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/hair-lit-300x300.webp">
<h5 class="Product-Disc">
للنساء الشعر والاضافر
تركيبة مطورة ٬ مكمل طبيعي
60 كبسولة نباتية
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/strong-carti/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/strong-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي من
sante magasin
حل للسياتيك والروماتيزم
60 كبسولة نباتية
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/pure-skin/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/pure-skin-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي
من sante magasin
بشرة صافية خالية
من الشوائب والبثور
60 كبسولة نباتية
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/maca/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/maca-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي
من sante magasin
كبسولات جذور الماكا
الطبيعية - العضوية
محفز الطاقة والقوة
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/collagen-complex/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2021/11/collagine-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي
من sante magasin
كولاجين بحري
تركيبة طبيعية
60 كبسولة نباتية
</h5>
<p class="Product-Prix">199 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/control-cholesterol/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/bio-cholesto-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي
من sante magasin
كوليسترول متوازن
محاربة الدهون الثلاثية
60 كبسولة نباتية
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/bio-oral-complement-alimentaire/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/bio-oral-300x300.webp">
<h5 class="Product-Disc">
مكمل لصحة الفم
حل طبيعي من المصدر
الرائحة الكريهة٫ اللثة
60 كبسولة نباتية
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/ibs-active-complement-alimentaire/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/ibs-300x300.webp">
<h5 class="Product-Disc">
مستخلصات طبيعية
300 ملغرام - 60 كبسولة
راحة الجهاز الهضمي
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/saw-palmetto/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/palmetto-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي
من sante magasin
للرجال - صحة البروستاتا
مستخلصات طبيعية
60 كبسولة نباتية
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
<div class="card2">
<a href="https://ma.santemagasin.com/produit/zen-stress/">
<div class="card-img2">
<img src="https://ma.santemagasin.com/wp-content/uploads/2022/09/zen-strees-300x300.webp">
<h5 class="Product-Disc">
مكمل طبيعي مغربي
من sante magasin
نوم مريح - حل للتوتر العصبي
60 كبسولة نباتية
</h5>
<p class="Product-Prix">249 د.م.</p>
<span class="Stars">★★★★★</span>
</div>
</a>
</div>
</div>
</div>
<div class="cover2">
<button class="left" onclick="leftScroll2()">❮</button>
<button class="right" onclick="rightScroll2()">❯</button>
</div>
CSS
.cover2 {
padding: 0px 30px;
position: relative;
}
.left {
position: absolute;
right: -20px;
top:-170PX;
background-color: transparent !important;
color: #006f07 !important;
font-size: 20px;
font-weight: bold;
border-color: grey;
border-radius: 20%;
}
.right:hover {
background-color: #006F07 !important;
color: white !important;
}
.left:hover {
background-color: #006F07 !important;
color: white !important;
}
.right {
position: absolute;
left: -20px;
top:-170PX;
background-color: transparent !important;
color: #006f07 !important;
font-size: 20px;
font-weight: bold;
border-color: grey;
border-radius: 20%;
margin-left :-10px;
}
.scrollmenu-SLIDER2 {
width: 100%;
height: auto;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
overflow-y: hidden;
}
.container2 {
display: flex;
overflow-x: auto;
}
.card2 {
padding: 10px;
margin: 10px;
border-radius: 20px;
line-height: 1.2;
background-color: white;
text-align: center;
}
.card2 img{
border-radius: 10px;
}
.Product-Prix{
text-decoration:none;
color : #006f07;
font-size: 20;
font-weight: bold;
margin:5px !important;
}
.Product-Disc{
color: #789FD6;
font-size: 15px;
display: -webkit-box;
max-width: 200px;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-align: center;
padding-top: 5px;
margin: auto;
width: 100%;
}
.scroll-images {
width: 100%;
height: auto;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
overflow-y: hidden;
scroll-behavior: smooth;
-webkit-overflow-scrolling: touch;
}
.Stars{
display: flex;
justify-content: center;
color: orange;
letter-spacing: 0.5px;
font-size: 20px;
}
.card-img2 {
width: 09rem;
}
::-webkit-scrollbar {
display: NONE;
}
#media only screen and (max-width: 800px) {
.card-img2 {
width: 07rem;
}
.card-img3 {
width: 10rem;
}
.left , .right {
display:none;
}
.cover2{
padding: 0px 5px;
position: relative;
}
JS
<script>
function leftScroll2() {
const left = document.querySelector(".scroll-images2");
left.scrollBy(2000, 0) ;
}
function rightScroll2() {
const right = document.querySelector(".scroll-images2");
right.scrollBy(-2000, 0) ;
}
</script>
I tried give different classes for every element than the first slider but the same problem still stop the slider from going smoothly
Unable to set card footer as expected output
Expected output:
My Code:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-3">
<div class="card">
<img src="https://images.unsplash.com/photo-1523805009345-7448845a9e53?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=752&q=80" class="card-img-top" alt="...">
<div class="card-img-overlay">
<h5 class="card-title"></h5>
</div>
<div class="card-footer text-center">
<h6>
Africa
</h6>
<h4>
Kenya
</h4>
</div>
</div>
</div>
jsfiddle: https://jsfiddle.net/sidh_41/p8sdfy7u/2/
.card-footer:last-child {
border-radius: 0!important;
}
.card-footer {
padding: 0!important;
background-color: unset!important;
border-top: unset!important;
}
.text-center {
color: #fff;
}
.card-img-overlay {
display: flex;
flex-direction: column;
justify-content: flex-end;
height: 100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-3">
<div class="card">
<img src="https://images.unsplash.com/photo-1523805009345-7448845a9e53?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=752&q=80" class="card-img-top" alt="...">
<div class="card-img-overlay">
<h5 class="card-title"></h5>
<div class="card-footer text-center">
<h6>
Africa
</h6>
<h4>
Kenya
</h4>
</div>
</div>
</div>
</div>
Try this:
.card-footer:last-child {
border-radius: 0!important;
}
.card-footer {
padding: 0!important;
background-color: unset!important;
border-top: unset!important;
}
.text-center {
color: #fff;
}
.card-img-overlay {
display: flex;
flex-direction: column;
justify-content: flex-end;
height: 100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-3">
<div class="card">
<img src="https://images.unsplash.com/photo-1523805009345-7448845a9e53?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=752&q=80" class="card-img-top" alt="...">
<div class="card-img-overlay">
<h5 class="card-title"></h5>
<div class="card-footer text-center">
<h6 class="m-0 small">
AFRICA
</h6>
<h1>
Kenya
</h1>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="card">
<img class="card-img" src="https://images.unsplash.com/photo-1523805009345-7448845a9e53?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=752&q=80" alt="...">
<div class="card-img-overlay">
<h5 class="card-title"></h5>
<div class="card-footer text-center">
<h6>
Africa
</h6>
<h4>
Kenya
</h4>
</div>
</div>
</div>
</div></div>
I think you need to add another div surrounding the card. This div needs to have the class row
.img-wrapper{
position: relative;
text-align: center;
color: white;
}
.card-footer{
position: absolute;
top: 60%;
left: 50%;
transform: translate(-50%, -50%);
}
h3, h1{
color: #fff
}
<div class="col-md-3">
<div class="card">
<div class="img-wrapper">
<img src="https://images.unsplash.com/photo-1523805009345-7448845a9e53?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=752&q=80" class="card-img-top" alt="...">
<div class="card-img-overlay">
<h5 class="card-title"></h5>
</div>
</div>
</div>
<div class="card-footer text-center">
<h3>
Africa
</h3>
<h1>
Kenya
</h1>
</div>
</div>
</div>
<link href="https://www1.chester.ac.uk/sites/all/themes/global/css/app_chester.css" rel="stylesheet"/>
<div style="background: #eaeaea">
<div class="column row">
<div class="m-modal-video__column m-modal-video__column--primary">
<div class="m-modal-video m-modal-video--primary-full-width">
<div class="m-cta__vcenter"><h3 style="color: black; text-align: center;">Be Part of It</h3>
<p style="color: black; text-align: center;">Choose an innovative degree that has been designed with your employability at its core.</p>
</div>
</div>
</div>
<div class="m-modal-video__column m-modal-video__column--secondary">
<div class="m-modal-video m-modal-video--primary-full-width">
<div class="m-cta__vcenter">
<div class="m-modal-video__container m-modal-video__container--cinemascope" data-open="youtubemodal">
<a><img src="http://img.youtube.com/vi/Ily454tCpWE/maxresdefault.jpg">
<div class="m-modal-video__overlay m-modal-video__overlay--triangle">
<div class="m-modal-video m-modal-video__triangle"></div>
</div></a>
</div>
<div class="reveal large" id="youtubemodal" data-reveal data-reset-on-close="true">
<div class="m-video m-video--modal m-video--cinemascope"><iframe src="https://www.youtube.com/embed/Ily454tCpWE" frameborder="0" allowfullscreen=""></iframe></div>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
I've got a modal on my site, and use the following to display a thumbnail image:
http://img.youtube.com/vi/DxwrdB7A6-I/maxresdefault.jpg
The problem is the video has an aspect ratio of 21:9. I've used the following styles, but still get the black letterbox on both the top and bottom of the image. Is there a way to just display the YouTube thumbnail without the black letterbox?
&__container {
position: relative;
height: 0;
padding-bottom: 42.85714%;
overflow: hidden;
margin-bottom: 1rem;
a img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
I've modified your sample code to add two new CSS rules to correspond to a class your HTML already had with no styles:
.m-modal-video__container--cinemascope defines the container around your cinemascope-ratio image, using the padding-bottom trick you'd previously tried implementing.
.m-modal-video__container--cinemascope img defines the sizing and positioning of the image inside the above container. Knowing you want this image to maintain its aspect ratio and not stretch, I've removed the height: 100% rule (so the height is automatically calculated) and vertically centered the image with the top: 50% and transform: translateY(-50%) trick.
This is all needed because YouTube still produced a 16:9 JPG thumbnail for your video despite its 21:9 ratio, so we're essentially using this trick to hide the black bars in the image. I still see a tiny sliver poking through, but you slightly adjust your padding-bottom ratio if you were worried about that, or increase your img's width past 100%.
.m-modal-video__container--cinemascope {
position: relative;
height: 0;
padding-bottom: 42.85714%;
overflow: hidden;
}
.m-modal-video__container--cinemascope img {
position: absolute;
left: 0;
width: 100%;
top: 50%;
transform: translateY(-50%);
}
<link href="https://www1.chester.ac.uk/sites/all/themes/global/css/app_chester.css" rel="stylesheet" />
<div style="background: #eaeaea">
<div class="column row">
<div class="m-modal-video__column m-modal-video__column--secondary">
<div class="m-modal-video m-modal-video--primary-full-width">
<div class="m-cta__vcenter">
<div class="m-modal-video__container m-modal-video__container--cinemascope" data-open="youtubemodal">
<a><img src="http://img.youtube.com/vi/Ily454tCpWE/maxresdefault.jpg">
<div class="m-modal-video__overlay m-modal-video__overlay--triangle">
<div class="m-modal-video m-modal-video__triangle"></div>
</div>
</a>
</div>
<div class="reveal large" id="youtubemodal" data-reveal data-reset-on-close="true">
<div class="m-video m-video--modal m-video--cinemascope"><iframe src="https://www.youtube.com/embed/Ily454tCpWE" frameborder="0" allowfullscreen=""></iframe></div>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
Here's the problem:
For Chrome, Opera, Safari everthing is fine:
chrome, opera, edge thumb-bar
But firefox has a problem:
firefox thumbbar
The problem is caused by the x-scrollbar which pushes each ".thumbs" and
their children up. The children keep their aspect/ratio thanks to the
combination of height: 100% and object-fit contain, not leaving any gap between them, EXCEPT under firefox. It seems that ".thumbs" doesn't want to wrap correctly around its child image. The height gets adapted, but not the width. I've tried already different combinations of flex: - shorthands, but nothing helped.
.scroll_wrapper {
position: relative;
overflow: hidden;
height: 100px;
}
.thumbs_container {
position: absolute;
display: -webkit-box;
display: -moz-box;
display: -ms-flex;
display: -webkit-flex;
display: flex;
flex-flow: row nowrap;
overflow-x: scroll;
height: 100%;
width: 100%;
}
.thumbs {
display: -webkit-box;
display: -moz-box;
display: -ms-flex;
display: -webkit-flex;
display: flex;
flex-flow: column nowrap;
height: 100%;
}
.thumbs_imgs {
height: 100%;
object-fit: contain;
}
<div class="scroll_wrapper">
<div class="thumbs_container">
<div class="thumbs">
<img src="http://placeimg.com/170/110/any" alt="1" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/115/any" alt="2" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/120/any" alt="3" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/125/any" alt="4" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/130/any" alt="5" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/135/any" alt="6" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/135/any" alt="7" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/140/any" alt="8" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/145/any" alt="9" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/150/any" alt="10" class="thumbs_imgs"/>
</div>
</div>
</div>
I found a solution with a js-workaround:
firefox bug:
js loops through the width of each img and gives each parent ".thumbs" the corresponding width.
x-scrollbar-hide:
-js gets the height of the outer .scroll-wrapper
-js gets the difference of .thumbs_container - .thumbs to get the width of the scrollbar (exactly for each browser, because different)
-js gives the heights of .scroll-wrapper + scrollbar-height to .thumbs_container
window.onload = function() {
scrollbarHide()
}
function scrollbarHide(){
var modalThumbsScrollWrapper = document.getElementsByClassName("scroll_wrapper")[0];
var modalThumbsScrollWrapperHeight = modalThumbsScrollWrapper.offsetHeight;
var modalThumbsContainer = document.getElementsByClassName('thumbs_container')[0];
var modalThumbsContainerHeight = modalThumbsContainer.offsetHeight;
var modalThumbs = document.getElementsByClassName('thumbs')[0];
var modalThumbsHeight = modalThumbs.offsetHeight;
var scrollbarHeight = modalThumbsContainerHeight - modalThumbsHeight;
var newModalThumbsContainerHeight = modalThumbsScrollWrapperHeight + scrollbarHeight;
modalThumbsContainer.style.height = newModalThumbsContainerHeight + "px";
modalThumbsWidthCorrectionFF()
}
function modalThumbsWidthCorrectionFF(){
var modalThumbs = document.getElementsByClassName('thumbs');
var modalThumbsLength = modalThumbs.length;
var modalThumbsImgs = document.getElementsByClassName('thumbs_imgs');
for (var i = 0; i < modalThumbsLength; i++) {
modalThumbs[i].style.width = modalThumbsImgs[i].offsetWidth + "px";
}
}
.scroll_wrapper {
position: relative;
overflow: hidden;
height: 100px;
}
.thumbs_container {
position: absolute;
display: -webkit-box;
display: -moz-box;
display: -ms-flex;
display: -webkit-flex;
display: flex;
flex-flow: row nowrap;
overflow-x: scroll;
height: 100%;
width: 100%;
}
.thumbs {
display: -webkit-box;
display: -moz-box;
display: -ms-flex;
display: -webkit-flex;
display: flex;
flex-flow: column nowrap;
height: 100%;
}
.thumbs_imgs {
height: 100%;
object-fit: contain;
}
<div class="scroll_wrapper">
<div class="thumbs_container">
<div class="thumbs">
<img src="http://placeimg.com/170/110/any" alt="1" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/115/any" alt="2" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/120/any" alt="3" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/125/any" alt="4" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/130/any" alt="5" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/135/any" alt="6" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/135/any" alt="7" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/140/any" alt="8" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/145/any" alt="9" class="thumbs_imgs"/>
</div>
<div class="thumbs">
<img src="http://placeimg.com/170/150/any" alt="10" class="thumbs_imgs"/>
</div>
</div>
</div>
I'm using the Kendo-UI Tabstrip, and would like to add a class to one specific tabpanel. Is this possible? Using .SpriteCssClasses within the items.Add() section only seems to add the class to the tab itself, and not the actual panel.
Any help is greatly appreciated.
You can try to get the specific panel using the ID because kendo will add a div with specific ID depending on the name of the tab strip and the tab number (order), for example:
#(Html.Kendo().TabStrip()
.Name("Main")
.Items(Main =>
{
Main.Add()
.Text("test1 title").Content(#<text>
test1
</text>);
Main.Add()
.Text("test2 title")
.Content(#<text>
test2
</text>);
})
)
This will generate the following HTML:
<div class="k-tabstrip-wrapper" style="">
<div id="Main" class="k-widget k-tabstrip k-header" data-role="tabstrip" tabindex="0" role="tablist" aria-activedescendant="Main_ts_active">
<ul class="k-reset k-tabstrip-items">
<li class="k-item k-state-default k-first k-tab-on-top k-state-active" role="tab" aria-controls="Main-1" style="" aria-selected="true">
<span class="k-loading k-complete"></span>
test1 title
</li>
<li class="k-item k-state-default k-last" role="tab" aria-controls="Main-2" style="">
<span class="k-loading k-complete"></span>
test2 title
</li>
</ul>
<div id="Main-1" class="k-content k-state-active" role="tabpanel" aria-expanded="true" style="height: auto; overflow: hidden; opacity: 1; display: block;">
<div style="display: none; position: absolute; opacity: 0.8; background-color: rgb(255, 255, 255); z-index: 1001; width: 33.4px; height: 20px;" class="tata-ajax-loader">
<div style="background-position: center;background-repeat: no-repeat;height:100%;width:100%;background-color: transparent;" class="tata-ajax-loader-img"></div>
</div>
test1
</div>
<div id="Main-2" class="k-content" role="tabpanel" aria-expanded="false" style="height: auto; overflow: hidden; opacity: 0; display: none;" aria-hidden="true">
<div style="display: none; position: absolute; opacity: 0.8; background-color: rgb(255, 255, 255); z-index: 1001; width: 33.4px; height: 20px;" class="tata-ajax-loader">
<div style="background-position: center;background-repeat: no-repeat;height:100%;width:100%;background-color: transparent;" class="tata-ajax-loader-img"></div>
</div>
test2
</div>
</div>
</div>
Note the divs with IDs "Main-1" and "Main-2" are the IDs of the actual panels which is what you want from what I understand so you can add CSS on the IDs:
#Main-1 {
background-color: #E3F7A8;
}