Here you will see the start of the NotesFromCoachesForWrestlers component circled
The problem is When the notes on the component on the left increase the component on the right adds whitespace which I don't want, if anything I would want it at the bottom of the component.
PLease note so far I have tried:
position: relative and top: 0 on the containing div
It seems the card div with class card-body is growing
Even if I set the div to have a height of 50px it still grows tho
<div className="col-12">
<div className="d-flex flex-wrap justify-content-around">
<div className="card my-1 p-1 col-sm-12 col-md-6" style={{ border: "1.3px solid black" }}>
<div className="card-body">
<GradingDashboardMadeByLuke UID={wrestler1UID} />
<div
className="card-text"
style={{ color: "black", fontSize: "smaller" }}
>
The previous 5 Logins for {props.wrestler1FullName} were:{" "}
{allLoginsForWrestler1.map((login) => {
return (
<p>
<Moment fromNow>{login.login_was_created_at}</Moment> -{" "}
</p>
);
})}
</div>
</div>
<div>
<NotesFromCoachesForWrestlers UID={wrestler1UID} />
<SubmitNoteForWrestler
wrestlerID={wrestler1UID}
wrestlerFullName={props.wrestler1FullName}
/>
</div>
</div>
<div
className="card my-1 p-1 col-sm-12 col-md-6"
style={{ border: "1.3px solid #ff7824" }}
>
<div className="card-body">
<h5 className="card-title">
<strong>{/*{props.first_name} {personalInfo.last_name}*/}</strong>
</h5>
<GradingDashboardMadeByLuke UID={wrestler2UID} />
<div
className="card-text"
style={{ color: "black", fontSize: "smaller" }}
>
The previous 5 Logins for {props.wrestler2FullName} were:{" "}
{allLoginsForWrestler2.map((login) => {
return (
<p>
<Moment fromNow>{login.login_was_created_at}</Moment> -{" "}
</p>
);
})}
</div>
</div>
<div className="mb-auto">
<NotesFromCoachesForWrestlers UID={wrestler2UID} />
<SubmitNoteForWrestler
wrestlerID={wrestler2UID}
wrestlerFullName={props.wrestler2FullName}
/>
</div>
</div>
</div>
</div>
Related
I can't find how to give a class to innermost div in react-window. In my case a have a flex wrapper containing list of data divs. But because react-window's innermost div separates my wrapper and list items I cannot properly align my list items. Is there a workaround either to access to innermost div and change it's class or directly to manipulate it's style.
Here is what react-window produces me as html.
<div style="position: relative; height: 600px; width: 100%; overflow: auto; will-change: transform; direction: ltr;">
<div style="height: 31900px; width: 100%;"> // ***here is where I want to style or give a class because there should be a flex wrapper here***
<div id="0" class="card product-card"><a class="product-title" href="/">
</div>
<div id="1" class="card product-card"><a class="product-title" href="/">
</div>
<div id="2" class="card product-card"><a class="product-title" href="/">
</div>
<div id="3" class="card product-card"><a class="product-title" href="/">
</div>
</div>
Thanks!
You can customize inner element and rows of each element
const Row = ({ index, style }) => (
<div
className={index % 2 === 0 ? "RowEven" : "RowOdd"}
style={{
...style,
top: `${parseFloat(style.top) + PADDING_SIZE}px`
}}
>
item {index}
</div>
);
const Example = () => (
<List
className="List"
height={150}
innerElementType={innerElementType}
itemCount={51}
itemSize={ITEM_SIZE}
width={300}
>
{Row}
</List>
);
const innerElementType = forwardRef(({ style, ...rest }, ref) => (
<div
ref={ref}
style={{
...style,
height: `${parseFloat(style.height) + PADDING_SIZE * 2}px`
}}
{...rest}
className="innerClass"
/>
));
here is Code sandbox example
I build a layout for a series of team portraits using React and Tailwind:
{/* Portrait list */}
<div className="max-w-sm mx-auto md:max-w-none">
{/* Portrait container */}
<div className="grid gap-12 md:grid-cols-3 md:gap-x-6 md:gap-y-8 items-start">
{/* 1st Portrait */}
<article className="flex flex-col h-full" data-aos="fade-up">
<header>
<Link to="/blog-post" className="block mb-6">
<figure className="relative h-0 pb-9/16 rounded-sm">
<img className="absolute inset-0 w-full h-full object-cover transform hover:scale-105 transition duration-700 ease-out" src={require('../images/john_doe.png').default} width="416" height="582" alt="News 01" />
</figure>
</Link>
<h3 className="h4 mb-2">
<Link to="/blog-post" className="hover:text-gray-100 transition duration-150 ease-in-out">John Doe</Link>
</h3>
</header>
<p className="text-lg text-gray-400 flex-grow">Head of Operations </p>
</article>
*/}
{/* 2nd portrait */} ...
The layout turns out exactly as intended:
After switching the hardcoded elements into a single data-driven component called 'TeamTile' , the layout is no longer applied. While the data is passed correctly into the component and every piece of information is present, all portraits are now shown below each other on every device: Why is this?
{/* Portrait list */}
<div className="max-w-sm mx-auto md:max-w-none">
{/* Portrait container */}
<div className="grid gap-12 md:grid-cols-3 md:gap-x-6 md:gap-y-8 items-start">
<TeamTile />
</div>
</div>
The element is constructed as follows, replicating the hard coded setup
using <article className="flex-col flex h-full" data-aos="fade-up"> exactly as before to apply the layout:
function TeamTile() {
return (
<div>
{TeamData.map((item, index) => {
return (
<article className="flex-col flex h-full" data-aos="fade-up">
<header>
<Link to={item.link} className="block mb-6">
<figure className=" rounded-sm">
<ProgressiveImage
delay={1000}
src={item.portrait}
placeholder={item.placeholder}
>
{(src, loading) => (
<img
className="inset-0 object-cover transform hover:scale-105 transition duration-700 ease-out"
style={{ opacity: loading ? 0.5 : 1 }}
src={item.portrait}
alt={item.alt}
/>
)}
</ProgressiveImage>
</figure>
</Link>
</header>
<div>
<h3 className="h4 mb-2">{item.name}</h3>
<p className="text-lg text-gray-500 flex-grow">{item.title}</p>
</div>
</article>
);
})}
</div>
);
}
export default TeamTile;
Where is my mistake?
because you wrapped your article tag with div you must remove div tag.
function TeamTile() {
return (
<>
{TeamData.map((item, index) => {
return (
<article className="flex-col flex h-full" data-aos="fade-up">
<header>
<Link to={item.link} className="block mb-6">
<figure className=" rounded-sm">
<ProgressiveImage
delay={1000}
src={item.portrait}
placeholder={item.placeholder}
>
{(src, loading) => (
<img
className="inset-0 object-cover transform hover:scale-105 transition duration-700 ease-out"
style={{ opacity: loading ? 0.5 : 1 }}
src={item.portrait}
alt={item.alt}
/>
)}
</ProgressiveImage>
</figure>
</Link>
</header>
<div>
<h3 className="h4 mb-2">{item.name}</h3>
<p className="text-lg text-gray-500 flex-grow">{item.title}</p>
</div>
</article>
);
})}
</>
);
}
<div class="account-tile" qa-name="accountBlock">
<a
*ngIf="link"
class="account-detail-header"
[routerLink]="'/AccountDetails/' + account.index!"
>
<div qa-name="accountName" class="account-name">
{{ account.accountName }}
</div>
<div qa-name="accountNumber" class="account-number">
...{{ account.number | lastFour }}
</div>
<span>
<i class="gg-chevron-right"></i>
</span>
</a>
<div *ngIf="!link" class="account-detail-header">
<div qa-name="accountName" class="account-name">
{{ account.accountName }}
</div>
<div qa-name="accountNumber" class="account-number">
...{{ account.number | lastFour }}
</div>
</div>
<div class="available-balance-container">
<div class="flex">
<span class="negative-account" *ngIf="account.availableBalance! < 0"
>-</span
>
<span
[ngClass]="link ? 'format-dollar-link' : 'format-dollar-display'"
class="format-dollar"
>
$
</span>
<h2 qa-name="availableBalance">
{{ account.availableBalance | currency: '':'' | absolute }}
</h2>
<!--This is wheere the transfer button appears-->
<div class="parent=class">
<button class="button-right pull-right">Transfer</button>
</div>
</div>
<h3>Available Balance</h3>
</div>
</div>
I am trying to display a transfer button at the right corner to look like the picture above. How can I accomplish that? I tried creating a button and a class that pulls the button to the right. when I compile the code, the transfer button shows underneath the Account amount
You can add position: absolute to your transfer button.
.parent-class {
position: relative;
height: 100px;
border: 1px solid red;
}
.button-right {
position: absolute;
right: 10px;
}
<div class="parent-class">
<button class="button-right">Transfer</button>
</div>
Since I'm learning html/css I'm working and making some examples, and I want to create a div which would look like this, but my content is 'glued' together.
I've tried varios ways and noone of them is near this, since I'm really new to html / css!
If you run code below you might see it looks bad, there is no space between texts, nothing is vertically aligned, and I don't know how to position size to the middle of div.
Here is my code :
<div style={{ background: '#e1e1e1', marginBottom: '5px' }}>
<span id="delete" style={{ float: 'right', display: 'inline-block', padding: '2px 5px' }}>
x
</span>
<i className="icon ion-md-checkmark-circle" />
TestImg1.PNG
3.98KB
</div>
Could anyone help me to achieve this with explanation how it's done so I might learn a lot from it.
Thanks and cheers!
Thanks
You could use bootstrap's grid system instead.
<div class="container">
<div class="row row-grey align-items-center">
<div class="col-2">
<i class="material-icons icon-green">
check_circle
</i>
</div>
<div class="col-3">
File.png
</div>
<div class="col-6">
52kb
</div>
<div class="col-1">
x
</div>
</div>
</div>
Here's the fiddle
You could utilize Flexbox to handle the layout and ordering of your elements. Set display: flex on the parent <div>. Define the ordering of your elements using the ordering property with one being the first and three being the last. After that, assign margin-left: auto; to the delete element to push it to the end of the parent <div>. You can see the code rendered here: Codepen example
<div style={{ display: 'flex', background: '#e1e1e1', marginBottom: '5px', padding: '2px 5px' }}>
<span id="delete" style={{ order: '3', marginLeft: 'auto' }}>
x
</span>
<i className="icon ion-md-checkmark-circle" style={{ order: '1' }} />
<span style={{ order: '2', marginRight: '10px' }}>
TestImg1.PNG 3.98KB
</span>
</div>
You can also try Flex.
<div style={{ background: '#e1e1e1', marginBottom: '5px', display:flex }}>
<I style={{flex: 0}} className="icon ion-md-checkmark-circle" />
<span style={{flex: 1, marginLeft: 8px}}>
TestImg1.PNG
</span>
<span style={{flex: 1}}>
3.98KB
</span>
<span id="delete" style={{ flex: 0, padding: '2px 5px' }}>
x
</span>
</div>
display: flex is applied to the container.
flex: 1 applied to texts and it means automatically stretch with ratio 1.
flex: 0 applied to icons and it means don't stretch.
If you want to learn more, take a look at here
I am new to the Angular 8 framework. I am trying to implement animation using angular animations
Here is what the code looks like:
This component is in <div class="col-md-5"></div> as a parent div.
component.ts:
#Component({
selector: 'app-agent-bot',
templateUrl: './agent-bot.component.html',
styleUrls: ['./agent-bot.component.css'],
animations: [
trigger('bot_res_slide', [
transition('* => *', [
animate('2s', keyframes([
style({ transform: 'translate3d(-100%, 0, 0)', visibility: 'visible' }),
style({ transform: 'translate3d(0, 0, 0)' })
]))
])
])
]
})
component.html
<main>
<div class="bot shadow-sm" [ngStyle]="{height: botHeight}">
<div class="bot_header p-2 rounded-top">
<div class="row">
<div class="col-md-12">
<div class="color_blue">
<i class="fa fa-bandcamp" aria-hidden="true"></i>
<span class="ml-3">AGENT BOT</span>
</div>
</div>
</div>
</div>
<div class="bot_body rounded-bottom d-flex flex-column">
<div class="p-2">
<div class="bot_response" #bot_res_slide>
<div class="bot_response_msg">
Hello Agent! How may I help?
</div>
<div class="bot_response_msg_time">03:00pm</div>
</div>
<div class="user_response">
<div class="user_response_msg">
Hi..!
</div>
<div class="user_response_msg_time">03:01pm</div>
</div>
</div>
<div class="mt-auto d-flex border-top input_section">
<div class="canned_msg">
<img src="./../../../assets/icons/canned_icon.png" class="w-100 h-100">
</div>
<div class="h-100 w-100 border-left">
<input type="text" class="user_input" placeholder="Type here" />
</div>
<div class="send_msg_btn d-flex justify-content-center align-items-center px-3">
<i class="fa fa-paper-plane my-auto" aria-hidden="true"></i>
</div>
</div>
</div>
</div>
</main>
Here is what the output looks like:
The expected output is the animation should only work in the bot component and should not be displayed outside.
Where am I going wrong or where should I improve my code?
Add overflow: hidden to the message list container (.bot_body).
This will clip the child elements rendering outside the container
I do believe that your issue is in the way you've done a simple translateX job with the translate3d property. Your element is showing up from the far left because the syntax of transform3d(x, y, z) values and you've made it travel the whole page (100%). For a slide, I'd recommend changing to a transform: translateX(value) to use the best function for the job. As well as define the transform-origin to be aligned to the edge of your message/ bot container. #vishalbiswas also has a possible solution by using overflow: hidden on the containing element.
...
style({ transform: 'translateX(-100%)', visibility: 'visible' }),
style({ transform: 'translateX(0)' })
...
In CSS:
.bot-response {
overflow: hidden;
}