ReactJS container does not take up entire line - reactjs

I have a reactJS application where I display a heading at the top of the view and then some text under the heading. I am using this code to generate the view:
render() {
return (
<div>
<div className="container">
<div className="enrollment_heading_background">
<div className="row">
<div className="col-12 text-center">
<label>Online Enrollment</label>
</div>
</div>
</div>
</div>
<div className="container">
<div className="enrollment_background">
<div className="row">
<div className="col-12 text-center text_15">
<label>Participant Agreement for OnLine Enrollment</label>
</div>
</div>
</div>
</div>
</div>
)
}
And I have the following in my style sheet:
.enrollment_heading_background {
background-color: #b3ccff;
padding-top: 5px;
padding-left: 0px;
padding-right: 0px;
}
.enrollment_background {
background-color: #ffe6b3;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
}
This is what is showing in the view:
If you notice, there is whitespace on the left and on the right. I have been unsuccessful in getting the blue background of the heading to occupy the entire view and I have been unsuccessful in getting the beige background to occupy the entire view.
Any suggestions would be greatly appreciated.

Try:
<div className="enrollment_heading_background">
<div className="container">
<div className="row">
<div className="col-12 text-center">
<label>Online Enrollment</label>
</div>
</div>
</div>
</div>
<div className="enrollment_background">
<div className="container">
<div className="row">
<div className="col-12 text-center text_15">
<label>Participant Agreement for OnLine Enrollment</label>
</div>
</div>
</div>
</div>
The padding from your container is causing the white space. You can still keep the container padding but bring the background divs out so they wrap both containers and keep their 100% width.

Related

Bootstrap grid not displaying rows

I am wanting to display images in a row for this portfolio, but they are displaying in a column. I can't seem to find anything that says I am doing this wrong. Any help with this?
Here is the code:
<div className="portfolio-wrapper">
<div className="container">
<h1 className="text-center py-5">
Portfolio
</h1>
<div className="image-box-wrapper row justify-content-center">
<div className="portfolio-image-box">
<img className="portfolio-image" src={autismapp} alt="Autism Therapy app..."></img>
<div className="overflow"></div>
<FontAwesomeIcon className="portfolio-icon" icon={faSearchPlus} />
</div>
{/*-*/}
<div className="portfolio-image-box">
<img className="portfolio-image" src={rasp} alt="Raspberry Pi Card Scanner..."></img>
<div className="overflow"></div>
<FontAwesomeIcon className="portfolio-icon" icon={faSearchPlus} />
</div>
{/*-*/}
<div className="portfolio-image-box">
<img className="portfolio-image" src={client} alt="Client Application..."></img>
<div className="overflow"></div>
<FontAwesomeIcon className="portfolio-icon" icon={faSearchPlus} />
</div>
{/*-*/}
<div className="portfolio-image-box">
<img className="portfolio-image" src={server} alt="Server Application..."></img>
<div className="overflow"></div>
<FontAwesomeIcon className="portfolio-icon" icon={faSearchPlus} />
</div>
{/*-*/}
<div className="portfolio-image-box">
<img className="portfolio-image" src={github} alt="Github Projects..."></img>
<div className="overflow"></div>
<FontAwesomeIcon className="portfolio-icon" icon={faSearchPlus} />
</div>
</div>
</div>
</div>
Here is the CSS styling on the classNames. I am not sure what would make them not show as a row, but it may seem that some of my end tags may be messed up. It is difficult to tell.
.portfolio-image{
width: 15rem !important;
height: 8rem !important;
overflow: hidden;
border: 1px solid var(--primary-pink);
padding: 0 0.5rem;
}
.portfolio-image-box{
position: relative;
margin: 1rem;
overflow: hidden;
}
Please mention the CSS property you have applied on these className. Without these, it's difficult to find the issue.
I think the width of the inner div is set to 100%. Try to set the breakpoints and width of the image or the div.
Update: The className "portfolio-image-box" needs to be "portfolio-image-box col" to be recognized as apart of the grid. This is because columns are expected to be in rows.

Aligning text in Card, reactrap

So I want to align the text next to the image, but here is what I get
Here is my code
<Card>
<div class='container'>
<div className='row'>
<div className='col-12 col-md-5 mt-3'>
<CardImg src={history.image} alt={history.name} />
</div>
</div>
<div className='row'>
<div className='col-12 col-md-5 mt-3'>
<CardBody>
<CardText>{history.description}</CardText>
</CardBody>
</div>
</div>
</div>
</Card>
Any ideas?
Thanks,
Theo.
Try using flex property to container!
Using CSS:
.container {
display: flex;
}
I think you are using Bootstrap, this might be helpful to you!
Flex Property Bootstrap

p:nth-child(n) not working within css divs

I am trying to control the padding of the first, second and third p tags within a div but can't seem to get it working, below is the code I have
<div class="col-sm-6 col-xs-12 col-md-3 col-lg-3">
<div class="icon-box-3 wow fadeInUp" data-wow-delay="0.6s" data-wow-offset="150">
<div class="icon-boxwrap2"><i class="fa fa-medkit icon-box-back2"></i></div>
<div class="icon-box2-title">Free assessments</div>
<p>
We offer FREE 10 minute assessments at our clinics, to see if osteopathy is right for you.
</p>
<div class="iconbox-readmore">FAQs</div>
</div>
</div>
<div class="col-sm-6 col-xs-12 col-md-3 col-lg-3">
<div class="icon-box-3 wow fadeInDown" data-wow-delay="0.9s" data-wow-offset="150">
<div class="icon-boxwrap2"><i data-icon="\e609" class="icon-stethoscope icon-box-back2"></i></div>
<div class="icon-box2-title">Registered</div>
<p>
We are registered osteopaths with the General Osteopathic Council.
</p>
<div class="iconbox-readmore">About</div>
</div>
</div>
<div class="col-sm-6 col-xs-12 col-md-3 col-lg-3">
<div class="icon-box-3 wow fadeInUp" data-wow-delay="1.2s" data-wow-offset="150">
<div class="icon-boxwrap2"><i class="icon-ambulance icon-box-back2"></i></div>
<div class="icon-box2-title">Areas Covered</div>
<p>
The areas generally covered are North London and Hertfordshire, but please do ring to see if we will cover your area.
</p>
<div class="iconbox-readmore">FAQs</div>
</div>
</div>
<style>
.icon-box-3 p:nth-child(1) {
padding: 0 15px 37px 15px;
}
.icon-box-3 p:nth-child(2) {
padding: 0 15px 37px 15px;
}
.icon-box-3 p:nth-child(3) {
padding: 0 15px 37px 15px;
}
</style>
When I do the above, it makes the all three p tags use the same css selector and uses the following line for some reason
.icon-box-3 p:nth-child(3) {
padding: 0 15px 37px 15px;
}
I don't get where it's going wrong?
You need to apply nth-of-type and nth-child classes on parent selector. icon-box-3 is a child under a parent div, which is why your class selection is failing.
.icon-wrapper:nth-of-type(1) p {
background: red;
padding: 0 15px 37px 15px;
}
.icon-wrapper:nth-of-type(2) p {
background: green;
padding: 0 15px 37px 15px;
}
.icon-wrapper:nth-of-type(3) p {
background: blue;
padding: 0 15px 37px 15px;
}
<div class="col-sm-6 col-xs-12 col-md-3 col-lg-3 icon-wrapper">
<div class="icon-box-3 wow fadeInUp" data-wow-delay="0.6s" data-wow-offset="150">
<div class="icon-boxwrap2"><i class="fa fa-medkit icon-box-back2"></i></div>
<div class="icon-box2-title">Free assessments</div>
<p>
We offer FREE 10 minute assessments at our clinics, to see if osteopathy is right for you.
</p>
<div class="iconbox-readmore">FAQs</div>
</div>
</div>
<div class="col-sm-6 col-xs-12 col-md-3 col-lg-3 icon-wrapper">
<div class="icon-box-3 wow fadeInDown" data-wow-delay="0.9s" data-wow-offset="150">
<div class="icon-boxwrap2"><i data-icon="\e609" class="icon-stethoscope icon-box-back2"></i></div>
<div class="icon-box2-title">Registered</div>
<p>
We are registered osteopaths with the General Osteopathic Council.
</p>
<div class="iconbox-readmore">About</div>
</div>
</div>
<div class="col-sm-6 col-xs-12 col-md-3 col-lg-3 icon-wrapper">
<div class="icon-box-3 wow fadeInUp" data-wow-delay="1.2s" data-wow-offset="150">
<div class="icon-boxwrap2"><i class="icon-ambulance icon-box-back2"></i></div>
<div class="icon-box2-title">Areas Covered</div>
<p>
The areas generally covered are North London and Hertfordshire, but please do ring to see if we will cover your area.
</p>
<div class="iconbox-readmore">FAQs</div>
</div>
</div>

AngularJS Transition on click

I am kind of new with angular and I found this way to use ng-click and ng-show to show the div with information in when the user clicks the h3.
The only problem is that it just shows up and I would like is it fades in or slides down to be visible. :)
Is this gonna work or should I do another way??
<div class="col-sm-12">
<div>
<h3 class="no-margin-bottom toggleText" ng-click="showInfoHe = !showInfoHe"><i class="fa fa-plus-circle" aria-hidden="true"></i> Hälsoinformation</h3>
<hr class="no-margin-top hr-line">
</div>
</div>
<div class="col-xs-12 col-md-offset-3 col-md-9 margin-top" style="border: 1px solid purple" ng-show="showInfoHe">
<div class="row cats-attributes">
<p>info</p>
</div>
</div>
You can do this without ngAnimate,
by using css transitions and ngClass
what you want to do on click set a variable to true and then have a class that has opacity:1.
so
<div class="parent-div" ng-click="yourVariable = true">
<div class="child" ng-class={'opacity-class': yourVariable}>
</div>
</div>
and then in the css
.parent-div {
transition: opacity ease-in-out 1s;
}
.parent-div.child {
opacity:0;
}
.opacity-class {
opacity: 1;
}
EDIT:
here is an applied solution to the html structure you provided
<div class="col-sm-12">
<div>
<h3 class="no-margin-bottom toggleText" ng-click="showInfoHe = !showInfoHe"><i class="fa fa-plus-circle" aria-hidden="true"></i> Hälsoinformation</h3>
<hr class="no-margin-top hr-line">
</div>
</div>
<div class="show-info-container">
<div class="col-xs-12 col-md-offset-3 col-md-9 margin-top show-info" style="border: 1px solid purple" ng-class="{'opacity-class':showInfoHe}">
<div class="row cats-attributes">
<p>info</p>
</div>
</div>
</div>
css
.show-info-container {
transition: opacity ease-in-out 1s;
}
.show-info {
opacity:0;
}
.opacity-class {
opacity: 1;
}
notice i added a container div and removed the ng-show

How to destroy Charts in chartJS

I have an angular + Ionic app in which I am using chartJS to show some data. Now charts are implemented on a slider.
Link1 Link2 and there are similar linked issues.
The solution that I came across. from many of the post is that I would have to destroy the existing chart and recreate in my window. Because whenever I change options via a drop drow the view blows up, all slides instead of coming next to each other laterally, Start showing up vertically and when I change the device mode. It actually re renders the page and I can view it normally.
I have tried it using ng-if also but it doesn't work. So how do I destroy a chart in my angular App and then recreate it
Some HTML code as to how am I doing it.
<div ng-if="metricArray">
<ion-slide-box on-slide-changed="slideHasChanged($index)" style="height:50%">
<ion-slide ng-repeat="metric in metricArray">
<div style="text-align:center; margin-top:10px; color:#eee;">
{{metric.startDate}} {{metric.endDate}}
</div>
<canvas id="myCanvas" tc-chartjs-bar chart-options="options" chart-data="metric.data" auto-legend></canvas>
<div class="row" style="margin-top:30px;">
<div style="width:33%; text-align:center">
<h6 style="color:#eee">MAX</h6>
<div class="circleBase type1 " style="padding:15px; margin-left: auto; margin-right: auto;">
<h6 style="color:#eee">{{metric.max}}</h6>
<p style="color:#eee">{{metricUnit}}</p>
</div>
</div>
<div style="width:33%; text-align:center">
<h6 style="color:#eee">MIN</h6>
<div class="circleBase type1 " style="padding:15px; margin-left: auto; margin-right: auto;">
<h6 style="color:#eee">{{metric.min}}</h6>
<p style="color:#eee">{{metricUnit}}</p>
</div>
</div>
<div style="width:33%; text-align:center">
<h6 style="color:#eee">AVG</h6>
<div class="circleBase type1 " style="padding:15px; margin-left: auto; margin-right: auto;">
<h6 style="color:#eee">{{metric.avg}}</h6>
<p style="color:#eee">{{metricUnit}}</p>
</div>
</div>
</div>
</ion-slide>
</ion-slide-box>
</div>

Resources