How to add a linear gradient in the background image with bootstrap? - css

This is a react app .I want to add a linear gradient of 0.7 on the background image with bootstrap. But how?
<Carousel.Item>
<img className='banner-bg d-block w-100 bg-dark bg-gradient ' src='https://i.ibb.co/YQ8MmpM/hero-bg-1-1.jpg' ' />
<Carousel.Caption className='position-absolute top-0 start-0 text-start px-5 pt-5 mt-5 ms-5 '>
<h2 className='fw-bold display-4 px-5 '>
Get Your Amazing <br />
Car Solution
</h2>
<p className=' px-5'>Take payments online with a scalable platform that <br /> grows with your perfect business
</p>
<div className='lc-block d-grid gap-2 d-md-flex justify-content-md-start px-5'>
<a className='btn btn-danger px-4 me-md-2' href='#' role='button'>About Us</a>
<a className='btn btn-outline-secondary px-4' href='#' role='button'>Latest Projects</a>
</div>
</Carousel.Caption>
</Carousel.Item>

All you need to do is to add a .bg-gradient class to the element (a linear gradient will be added as background image to the backgrounds).
If you want to add in your custom CSS class,
Just add below line:
background-image: var(--bs-gradient);
You can target bootstrap gradient with below style in React:
style={{
backgroundImage: linear-gradient( 170deg, var(--bs-gradient), 'navy' )
}}
OR
Replace you image tag with below tag:
<img style={{backgroundImage:linear-gradient(170deg,var(--bs-gradient),'navy')}} className='banner-bg d-block w-100 bg-dark bg-gradient ' src='https://i.ibb.co/YQ8MmpM/hero-bg-1-1.jpg' ' />
If above code worked, change linear-gradient property values as per your requirement.

Related

why is the color of this button leaking

In a vuejs app and using tailwindcss, I have a strange behaviour on my button:
this is the template code:
<div
:class=" [ bubbled ? 'text-vert' : 'text-grisee' ] "
#click = "togglebubbled()"
class="mt-6"
>
<FontAwesome icon="soap" class="lg:text-lg mr-4 lg:mr-0" />
<span class="ml-2" >Rappel mois prochain</span>
</div>
<div class="w-fit m-auto">
<FormButton :disabled="disabled">Envoyer</FormButton>
</div>
And the FormButton template :
<div>
<button
type="submit"
class="mt-6 px-5 py-3 drop-shadow-2xl hover:drop-shadow-none transition ease-in-out duration-300 rounded leading-snug whitespace-nowrap text-base font-semibold text-blanc"
:class="[disabled ? 'bg-grisee' : 'bg-bleulfdm hover:bg-marron']"
:disabled="disabled"
>
<slot></slot>
</button>
</div>
I have no explanation or solution for this effect, which is flickering, sometimes showing button correctly, sometimes leaking

How i reposition a number of cart position

I try so many times to adjust the number of cart but it always span in the center position and not in the top of cart logo, I did everything but it always comes out of there. thanks for the help in advance i appreciate your answer :)
`enter image description here
this is my code for:
<Link href="/cart">
<a className="p-2">
<Image src="/image/cart.png" alt="" width={20} height={20} />
</a>
</Link>
{cartItemsCount > 0 && (
<span className="rounded-full bg-red-600 px-2 py-1 text-xs font-bold text-white">
{cartItemsCount}
</span>
)}
</div>

How to focus a div tag with a tailwind?

I'm using tailwind and Vue to make some reusable toggle component. Border of component is gray color, but plan is when I click on component, border will be red like on a image below (I'm using/trying using focus).
Problem is because I can use focus just on input and button, but I need focus on div tag
I have one div, inside is two paragraph and one input (type:checkbox). I tried with tabindex and it doesn't work, when I click in checkbox or input field (gray button) it doesn't focus. Only focuses when I click inside a component but not in checkbox field.
Code is
<template>
<div>
<div tabindex="1"
class="relative border border-gray-300 px-10 max-w-md mx-auto my-2 cursor-pointer rounded-lg px-5 py-4 rounded-lg border bg-white transition duration-150
ease-in-out placeholder:text-zinc-400 hover:bg-zinc-100 focus:border-transparent
focus:outline-none focus:ring disabled:opacity-50 motion-reduce:transition-none
dark:bg-zinc-900 dark:placeholder:text-zinc-500 dark:hover:bg-zinc-800" :class="[ error
? 'border-red-500 caret-red-500 focus:ring-red-500/50'
: 'border-zinc-300 caret-primary focus:ring-primary/50 dark:border-zinc-600 dark:focus:border-transparent',
]"
>
<div class="flex justify-between">
<div>
<h1 class="text-md font-semibold text-black">
{{ titleToggle }}
</h1>
<p class="inline text-md text-gray-500">
{{ subtitleToggle }}
</p>
</div>
<label class="switch my-auto">
<input
:value="toggleSwitch"
v-bind="$attrs" type="checkbox"
class="rounded-lg " :class="[
error
? 'border-red-500 caret-red-500 focus:ring-red-500/50'
: 'border-zinc-300 caret-primary focus:ring-primary/50
dark:border-zinc-600 dark:focus:border-transparent',]" #click="updateInput"
>
<span :class="[toggleSwitch ? 'bg-red-500 border-red-500' : 'bg-gray-300 border-gray-300',
]" class="slider round absolute cursor-pointer inset-0 border rounded-full"
/>
</label>
</div>
</div>
</div>
</template>
Is anyone have advice, or maybe different way how to do it ?
I don't really understand your question, but you may have a look at this from the tailwind documentation :
focus-within (:focus-within) : Style an element when it or one of its descendants has focus using the focus-within modifier:
<div class="focus-within:shadow-lg ...">
<input type="text" />
</div>
https://tailwindcss.com/docs/hover-focus-and-other-states#focus

Tailwind using the top of an image for a circle profile pic

I have an image
231x419
this size won't change, but the scale might.
I want to display a smaller profile image but only filling the circle with a part of the top of the image.
Basically just showing the circle part in the image above.
This circle area will be shown on a header.
Not sure what the best way to go about this, where the full image does not distort the header height etc.
My current circle image is:
<a href="#" className="block relative">
<img
alt="name"
src="/images/1.jpg"
className="h-10 mx-auto object-cover rounded-full w-10"
/>
</a>
I don't think this is quite what you wanted as I am not sure how it would handle different sizes. I can delete the answer or leave it here if it will help anyone.
I gave it a go using object-none and then a custom class that sets the object-position.
See how this looks,
https://play.tailwindcss.com/XnHzOUO2IO
<a href="#" className="block relative">
<img
alt="name"
src="https://i.stack.imgur.com/HgkK0.png"
className="object-none w-36 h-36 rounded-full custom-position" />
</a>
.custom-position {
object-position: 60% -3px;
}
In addition to #stickyuser's answer, you can avoid having custom class by using object-[59%_-4px] class.
Tailwind playground: https://play.tailwindcss.com/olB8hotsAX
<a href="#" className="block relative">
<img alt="name" src="https://i.stack.imgur.com/HgkK0.png" class="h-36 w-36 rounded-full object-none object-[59%_-4px]" />
</a>
It can be also done with background position:
<a href="#" className="block relative">
<div class="h-36 w-36 rounded-full bg-[59%_-4px]" style="background-image:url(https://i.stack.imgur.com/HgkK0.png)"></div>
</a>

anchor tag design changes in mobile safari

so am designing this website and my anchor tags looks fine in desktop and android mobiles but in safari it changes to a pill type button. i mean thhe (how it works and pricing buttons)
but originally it should look like this
this is the code of those two buttons
<a href="/" type="button" class="btn text-white active p-2 pt-4 pb-4 " style="font-family:roboto;font-size: 18px;">
text.How it works
</a>
<a href="/" type="button" class="btn text-center text-white p-2 pt-4 pb-4 " style="font-family:roboto; font-size: 18px;">
Pricing
</a>
You can try removing type="button" from anchor tag.

Resources