The text should be in white badge with text center . I use gatsby StaticImages by the way....
Code..
<div class="row mx-4" style={{ position:'relative' }}>
<StaticImage style={{ position:'absolute', filter: 'brightness(100%)' }} src="../images/scrollg.png" alt="tatil" placeholder="tracedSVG" />
<div className="d-flex justify-content-end pt-4 pe-4" >
<StaticImage src="../images/badge.svg" alt="tatil" placeholder="tracedSVG" />
<div style={{ position:'absolute'}}> <p className="text-center">200€’dan başlayan fiyatlarla</p></div>
</div>
<div className="row mx-5 scrollg" style={{ position:'absolute' , height:'400px'}}>
<div className="col-12 my-auto">
<h4 className="fw-bold text-white">Roma’yı Keşfetme Mevsimi</h4><br />
<p className="col-lg-5 col-md-5 col-sm-12 scrollg">Haydi, siz de Tatilbudur’un uygun fiyatlı yurt dışı turlarını incelemeye başlayın, yurt dışında daha fazla yeni yerler keşfetmenin keyfine varın!</p>
<button class=" px-3 py-1 scrollg-button rounded-pill "> Fırsatları Gör</button>
</div>
</div>
</div>
The text here needs to be positioned absolutely and relative to the parent div element within which the text and the image are. So you'll have to add position-relative class to the parent.
To center the text vertically, you can add equal distance on the top and bottom.
To make sure the text is within the white badge, you can add some fixed width to th text div.
<div className="d-flex justify-content-end pt-4 pe-4 position-relative">
<StaticImage src="../images/badge.svg" alt="tatil" placeholder="tracedSVG" />
// I've added 100px width as an example.
<div style={{ position:'absolute', top: '25%', bottom: '25%', width: '100px'}}>
<p className="text-center">200€’dan başlayan fiyatlarla</p>
</div>
</div>
Related
I have an issue with box sizing that includes general information. Depending if a particular card has an image, then card is bigger or smaller. How I can keep the box always with the same size?
<div className='card' syle='max-height:300px'>
<img onError="this.src= 'https://d27jswm5an3efw.cloudfront.net/app/uploads/2019/07/insert-image-html.jpg'" className="card-img top max-height:50px" src={item.img !== undefined ? item.img : "https://d27jswm5an3efw.cloudfront.net/app/uploads/2019/07/insert-image-html.jpg"}/>
<div className="card-body" syle='max-height:300px'>
<h3 className="card-title">{item.subject}</h3>
<p className="card-text">{item.description}</p>
<div className="col-8-center">
<div className="row justify-content-center">
<div className='col-3 text-center'>Likes: <strong>{item.likes}</strong></div>
</div>
<button type='button' className='col-4 border bg-danger justify-content-center text-white btn-lg'>Dislike</button>
<button type='button'className='col-4 border bg-success text-center text-white'>Like</button>
</div>
</div>
</div>
This is how it's displayed now:
Entries without a picture:
Entry with a picture:
I am using Tailwind CSS to style a Next.js website.
I have an image element for which I am using Next.js Image element.
Now I want to open a modal on top of the current page. But I don't want to completely black out the underlying page, just dim it. For this I am using an absolutely positioned element with a 50% opacity on top of everything else.
With my current setup, everything below the absolutely positioned element does get dimmed, except for the Image elements which seem unaffected from everything.
The jsx looks like this:
<div>
<div className='absolute inset-0 flex items-center justify-center bg-black'>
<h1 className='bg-gray-600'>MODAL</h1>
</div>
<div className='px-auto mx-32 grid grid-cols-2 gap-3'>
<h1 className='col-span-2 my-5 text-3xl font-black'>
Header
</h1>
<div id='CardElem'>
<div id='memberCard' className='p-3 shadow-2xl'>
<Image alt='avatar' width=250 height=250 src='imgSrc' />
<h1 className='text-2xl font-black'>text1</h1>
<h2 className='text-xl font-bold'>text2</h2>
<h3 className='text-lg'>text3</h3>
</div>
</div>
<div id='CardElem'>
<div id='memberCard' className='p-3 shadow-2xl'>
<Image alt='avatar' width=250 height=250 src='imgSrc' />
<h1 className='text-2xl font-black'>text4</h1>
<h2 className='text-xl font-bold'>text5</h2>
<h3 className='text-lg'>text6</h3>
</div>
</div>
</div>
</div>
With this setup, every h1, h2, h3 gets dimmed by the absolute div. Only the two Image tags stay fully visible.
Is there something wrong with my setup?
The issue was the order of the elements. The absolutely positioned element should be below the other elements
<div>
<div className='px-auto mx-32 grid grid-cols-2 gap-3'>
<h1 className='col-span-2 my-5 text-3xl font-black'>
Header
</h1>
<div id='CardElem'>
<div id='memberCard' className='p-3 shadow-2xl'>
<Image alt='avatar' width=250 height=250 src='imgSrc' />
<h1 className='text-2xl font-black'>text1</h1>
<h2 className='text-xl font-bold'>text2</h2>
<h3 className='text-lg'>text3</h3>
</div>
</div>
<div id='CardElem'>
<div id='memberCard' className='p-3 shadow-2xl'>
<Image alt='avatar' width=250 height=250 src='imgSrc' />
<h1 className='text-2xl font-black'>text4</h1>
<h2 className='text-xl font-bold'>text5</h2>
<h3 className='text-lg'>text6</h3>
</div>
</div>
</div>
<div className='absolute inset-0 flex items-center justify-center bg-black'>
<h1 className='bg-gray-600'>MODAL</h1>
</div>
</div>
I have a built a split page layout that, is perfectly aligned as it was intended:
Constructed using:
<div className="flex flex-wrap">
<div className="w-full md:w-1/2 h-screen overflow-hidden order-last lg:order-first md:order-first">
<div className="flex h-screen">
<div class="m-auto max-w-3xl px-5">
{TeamData.slice(0, 1).map((item, index) => {
return (
<div>
<h1 className="text-3xl xs:text-2xl md:text-3xl lg:text-5xl xl:text-6xl mb-5">{item.name}</h1>
<p className="text-xl leading-10 uppercase mb-5 text-gray-700">{item.title}</p>
<p className="text-xl leading-10 mb-5">{item.bio}</p>
</div>
);
})}
</div>
</div>
</div>
<div className="bg-green w-full md:w-1/2 h-screen order-first lg:order-last md:order-last">
<img className=" object-contain h-screen w-full" src={require('../images/johne_doe.png').default} data-aos="fade-up" alt="John Doe" />
</div>
</div>
Upon screen resizing to sizes smaller than 1440px in width, however, the portrait images get considerably offset from the bottom.
How can I keep in its bottom alignment on smaller viewports using tailwind?
Add object-bottom to an image tag.
Yoг can find information about object-{side} here
As you can see, i do have 3 bootstrap cards having 3 images with different heights. I want to make the images having same height compared to others (like the bigger one "takes the lead" and all the other one in the row adapting to this bigger one).
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-lg-4 col-md-6 mb-4">
<div class="card h-100">
<img class="card-img-top" src="/images/produits/1" alt=""><hr>
<div class="card-body">
<h6 class="card-title">
slt la mif
</h6>
<small class="text-muted">Puissance : 10 à 100W</small>
</div>
</div>
</div>
I already put the h-100 class in the card div but it only adapts the card's height, and I want the images to be adapted (in order to not have the blank after the text), how to do that pls?
Bootstrap class card-body has property flex: 1, it means, that this element also grows for available space.
You can add some special class, for example to row, or higher, where you use card, to modify that parameter. Something like that.
.special .card-body {
flex-grow: 0;
}
Also wrap link image with div which has class="flex-fill", it makes grow the link images.
Look into the snippet, I;ve added special class to row, and set different height to link images to illustrate the idea.
UPDATE. Made link images center
Play with flexboxes. For example: add to div which wraps <a> class d-flex it will make this div with display: flex. And then you can add to this div classes justify-content-center and align-items-center, but I prefer in your case to add class m-auto to <a>, it gives margin: auto, which make element centralized with flex parent. Look into snippet.
.special .card-body {
flex-grow: 0;
}
.img_mock1 {
padding: 50px;
background-color: red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="row special">
<div class="col-lg-4 col-md-6 mb-4">
<div class="card h-100">
<div class="flex-fill d-flex">
<span class="img_mock1"></span>
</div>
<hr>
<div class="card-body">
<h6 class="card-title">
slt la mif
</h6>
<small class="text-muted">Puissance : 10 à 100W</small>
</div>
</div>
</div>
<div class="col-lg-4 col-md-6 mb-4">
<div class="card h-100">
<div class="flex-fill d-flex">
<a href="/led/catalogue/produit/1" style="height:300px;" class="m-auto">
<img src="" alt="">
</a>
</div>
<hr>
<div class="card-body">
<h6 class="card-title">
slt la mif
</h6>
<small class="text-muted">Puissance : 10 à 100W</small>
</div>
</div>
</div>
</div>
Use the following CSS
.card-img-top {
width: 100%;
height: 15vw;
object-fit: cover;
}
The object-fit: cover; enables zoom instead of image stretching.
Give fix height suppose 150px to the wrapper of image(anchor tag). Then for the image tag use max-width: 100%, height: auto, display: block
give the image div a fixed height, use the height preference of the largest image to put a fix height on the dive of the image, this will allow the all to show the same way.
So I'm writing a code where I need to evenly place cards next to each other with rows when using flex. However, I'm getting some spacing on the right side and can't work out a reason why is that happening. I tried inspecting the element, but it just shows the entire card extends to the right, but there is no real reason behind why it does that. I've scrolled through CSS code, and there's no additional width on the right.
<section id="jobs">
<!--Employing cards-->
<div class="container-fluid container-fluid-shorter bg-white">
<!--Assistant card-->
<div class="row">
<div class="col-md-6 col-lg-4 my-3">
<div class="card width-37">
<div class="card-body d-flex align-items-center justify-content-between">
<h6 class="card-title font-weight-lighter pb-3">Custom units</h6>
<p class="card-text">
<h4 class="text-grey font-weight-light text-capitalize pb-3 pt-3">home page hero</h4>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4 my-3">
<div class="card width-37">
<div class="card-body d-flex align-items-center justify-content-between">
<h5 class="card-title font-weight-lighter pb-3">Vlastní jednotky</h5>
<p class="card-text">
<h4 class="text-grey font-weight-light text-capitalize pb-3 pt-3">home page hero</h4>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4 my-3">
<div class="card width-37">
<div class="card-body d-flex align-items-center justify-content-between">
<h5 class="card-title font-weight-lighter pb-3">Vlastní jednotky</h5>
<p class="card-text">
<h4 class="text-grey font-weight-light text-capitalize pb-3 pt-3">home page hero</h4>
</div>
</div>
</div>
</div>
</div>
<!--End of employing cards section-->
</section>
Adjustments I've made to the CSS :
.width-37{
max-width: 37.5vh;
}
.card-body{
padding-left: 0; !important;
padding-right: 0; !important;
}
I'm trying to place all the items in the row where there is a small spacing between each item and all items will create rows as you set rows for different screen sizes large, medium, small. For some reason flex item is doing spacing on the right side of each item there is. It is 480 pixels wide and 180 height. I would like it to be 180 x 180 pixels so same height and width. Anyone got an idea on why is this happening?
.width-37{
max-width: 37.5vh;
}
This is causing the spacing on right side. Also, there should be no ; before !important
This is due to how block level elements are rendered and not a Flexbox specific issue. Block level elements always take up the full width of the containing element. If you set a width on a block level element, and it does not fill the containing element, the remaining space will be filled with margin.
Example
div {
min-height: 24px;
}
div:nth-child( 1 ) {
width: 100px;
background-color: rebeccapurple;
}
div:nth-child( 2 ) {
max-width: 200px;
background-color: gold;
}
div:nth-child( 3 ) {
width: 20vw;
background-color: silver;
}
<div></div>
<div></div>
<div></div>
The default flow of content is left to right and why the element is to the left. All the space to the right of each element is margin. This is what is happening inside of your Bootstrap column elements.
This is the why
*Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins. This way, all the content in your columns is visually aligned down the left side.
Documentation here
In order to remove the padding on your gutter you can add the class no-gutters to your row.