restrict height of collapsed accordion segment Bootstrap 5 Vue3 - vue.js

I am building a web app with Vue3 and bootstrap 5. But I think this issue only concerns bootstrap. What I want to do is to restrict the height of the collapsed accordion segment, so it does not kick the other segments too far down when its content is long.
What I tried is to add max-height and overflow: auto to the class .collapsing and I already added "collapsing" to the classes of the accordion but then the accordion scrolls to the height and after a second jumps to full unfolding. In the node_modules bootstrap folder, I looked into the _accordion.scss and changed "overflow-anchor" to auto and nothing changed.
.collapsing {
max-height: 100px !important;
overflow: auto !important;
}
On this example file i just took the accordion example from bootstrap(under "Flush") so my vue file looks like this:
<template>
<div class="accordion accordion-flush" id="accordionFlushExample">
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingOne">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#flush-collapseOne"
aria-expanded="false"
aria-controls="flush-collapseOne"
>
Accordion Item #1
</button>
</h2>
<div
id="flush-collapseOne"
class="accordion-collapse collapse"
aria-labelledby="flush-headingOne"
data-bs-parent="#accordionFlushExample"
>
<div class="accordion-body">
Placeholder<br />this must be long <br />this must be long <br />this
must be long <br />this must be long <br />this must be long
<br />this must be long <br />this must be long <br />this must be
long <br />this must be long(thats what she said) <br />
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingTwo">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#flush-collapseTwo"
aria-expanded="false"
aria-controls="flush-collapseTwo"
>
Accordion Item #2
</button>
</h2>
<div
id="flush-collapseTwo"
class="accordion-collapse collapse"
aria-labelledby="flush-headingTwo"
data-bs-parent="#accordionFlushExample"
>
<div class="accordion-body">
Placeholder content for this accordion, which is intended to
demonstrate the <code>.accordion-flush</code> class. This is the
second item's accordion body. Let's imagine this being filled with
some actual content.
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "stackoverflowquestion",
};
</script>
<style>
.collapsing {
max-height: 100px !important;
overflow: auto !important;
}
</style>
any ideas? Thanks

Found it!
You gotta put the class in the accordion-body.
So at first define a class like
.restrict-collapsing {
max-height: 100px !important;
overflow: auto !important;
}
then call it within the same bracket as accordion-body
<div class="accordion-body restrict_collapsing">
Placeholder<br />this must be long <br />this must be long <br />this
must be long <br />this must be long <br />this must be long
<br />this must be long <br />this must be long <br />this must be
long <br />this must be long(thats what she said) <br />
</div>

Related

Razor #{ } method on .cshtml page not allowing text or href selection

I have scaffolded my RegisterConfirmation page in .Net Core identity. My cshtml code is below.
#page
#model RegisterConfirmationModel
#using LazZiya.ExpressLocalization
#inject ISharedCultureLocalizer _loc
#{
ViewData["Title"] = _loc[Model.PageTabTitle];
}
#section header_image{
<div class="bg-img-non-home" id="RegisterPageBanner">
}
#section header_content{
<div class="container-title">
<div class="block-title">
<br>
<h1 class="block-subtitle-text" id="RegisterPageSubtitle">#_loc[Model.SubTitle]</h1>
<h2 class="block-title-text-non-home" id="RegisterPageTitle">#_loc[Model.Title]</h2>
</div>
</div>
}
</div>
<body class="body-bg-img">
<div class="container-body">
<div class="row justify-content-center align-items-center">
<div class="col">
<br />
<h2 class="font-style-content-head" id="RegisterConfHeading">#_loc[Model.Heading]</h2>
<hr />
</div>
</div>
<br />
</div>
<div class="container-body">
<div class="row justify-content-center align-items-center">
<hr />
#{
if (#Model.DisplayConfirmAccountLink)
{
<p>
This app does not currently have a real email sender registered, see these docs for how to configure a real email sender.
Normally this would be emailed: <a id="confirm-link" href="#Model.EmailConfirmationUrl">Click here to confirm your account</a>
</p>
}
else
{
<p>
Please check your email to confirm your account.
</p>
}
}
</div>
</div>
</body>
If the #section header_content is present everything on the page displays. But the text from my if statement cannot be highlighted with the mouse and the a href links cannot be clicked. If I delete the code section below, then the text from my if statement can be highlighted using the mouse and the href works fine.
#section header_content{
<div class="container-title">
<div class="block-title">
<br>
<h1 class="block-subtitle-text" id="RegisterPageSubtitle">#_loc[Model.SubTitle]</h1>
<h2 class="block-title-text-non-home" id="RegisterPageTitle">#_loc[Model.Title]</h2>
</div>
</div>
}
</div>
UPDATE: When I zoom in it works fine. Also, if I add lots of text inside the if statement, it doesn't wrap it simply goes past the width of the body-bg-img image. I can select the text when it is past the width of the page...
This is more a workaround than an answer. By pushing my text down the page using line breaks, it works fine. Not a solution for most other pages, but because this is only the register confirmation with few components on the page, I can make it work.
I'm guessing it is a css sizing issue with my #section header_image. One solution would probably be to check the css, or perhaps create a chopped header image with reduced height and use it on this page. But I don't need to bother in this case.
<body class="body-bg-img">
<div class="container-body">
<div class="row justify-content-center align-items-center">
<div class="col">
<br />
<br />
<h2 class="font-style-content-head" id="RegisterConfHeading">#_loc[Model.Heading]</h2>
<hr />
</div>
</div>
<br />
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<div class="container-body">
<div class="row justify-content-center align-items-center">
#{
if (#Model.DisplayConfirmAccountLink)
{
<p>
This app does not currently have a real email sender registered, see these docs for how to configure a real email sender.
Normally this would be emailed: <a id="confirm-link" href="#Model.EmailConfirmationUrl">Click here to confirm your account</a>
</p>
}
else
{
<p>
Please check your email to confirm your account.
</p>
}
}
</div>
</div>
</body>
Update:
The above lasted about 60 seconds and I couldn't tolerate it! :) The issue was a hardcoded height value for my block-title css style. I changed it to auto and it is fine now. Still have a bit of tidying up to get the overall look back to my pages, but issue is resolved.
.block-title {
width: 520px;
height: auto;
text-align: center;
}

How to vertically align text field with it's label and button

I'm basically trying to have this kind of layout:
Label TextField Button
So e.g:
Number of copies [5 ] [Add]
Thought that would be really simple to do. But I've struggled for a few hours now, and this is the closest I've come, which is absolutely terrible:
Here's my code:
<div class="row col-md-12">
<form class="form-inline pull-right">
<div class="form-group">
<label for="numberOfCopies">Number of copies</label>
<input size="1" type="text" class="form-control" id="numberOfCopies">
<button type="submit" class="btn btn-primary">Add</button>
</div>
</form>
</div>
At first some Bootstrap-Basics:
your 'row-div' should be wrapped by a 'container-div'
row and col-xx-x classes need to be on their own div-tags
as you can see at the example below, you could easily get this done using css.
With display: flex; we get all elements of the form-group side by side.
With white-space: nowrap we 'tell' the label to be shown as one-line only.
Using the margin-tags we will get the elements to the right position.
To learn more take a look at the documentations of display, white-space and margin.
I think the usage of input-groups could be interesting, too. Feel free to ask per comment, if anything is unclear.
.form-group.flex {
display: flex;
}
.form-group.flex label {
white-space: nowrap;
margin-top: 7px;
}
.form-group.flex input {
margin: 0 7px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container">
<div class="row">
<div class="col-md-12">
<form class="form-inline pull-right">
<div class="form-group flex">
<label for="numberOfCopies">Number of copies</label>
<input size="1" type="text" class="form-control" id="numberOfCopies">
<button type="submit" class="btn btn-primary">Add</button>
</div>
</form>
</div>
</div>
</div>

Bootstrap accordion icons not working on collapsed states

I am working on a accordion in Bootstrap V 3.37. I have icons on the accordion which change with open and closed states. When I the state set to collapse init works fine. But when I have the accordion with none of them accordions collapsed in the icons are not working properly.
The icons should be working as:
Arrow facing down on closed state
Arrow facing up on open state
My code is as follows so far:
HTML Structure
<!-- Panel list accordion -->
<div class="panel-group">
<div class="panel-heading-one panel-main-heading-one">
<h4 class="panel-title panel-main-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
<img src="../images/image.svg" class="panel-icon">
<p>Title here</p>
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body panel-bodymain-one">
<p>Text body here</p>
</div>
</div>
<div class="panel-heading-one panel-main-heading-one">
<h4 class="panel-title panel-main-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
<img src="../images/image.svg" class="panel-icon">
<p>Title here</p>
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body panel-bodymain-one">
<p>Title body here</p>
</div>
</div>
<div class="panel-heading-one panel-main-heading-one">
<h4 class="panel-title panel-main-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
<img src="../images/image.svg" class="panel-icon">
<p>Title here</p>
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body panel-bodymain-one">
<p>Text body here</p>
</div>
</div>
</div>
</div>
<!-- End panel list accordion -->
CSS
.panel-heading-one .accordion-toggle:after {
/* symbol for "opening" panels */
font-family: 'Glyphicons Halflings';
content: "\e113";
float: right;
color: #ffffff;
height: 24px;
width: 40px;
background-color: #000000;
}
.panel-heading-one .accordion-toggle.collapsed:after {
/* symbol for "collapsed" panels */
content: "\e114";
}
Screenshots attached also.
Closed state - still point up:
Open state is fine as it points up:
Any help would be great.
Change your css to:
.panel-heading-one .accordion-toggle:after{
font-family: 'Glyphicons Halflings';
content: "\e114";
float: right;
color: #ffffff;
height: 24px;
width: 40px;
background-color: #000000;
}
.panel-heading-one .accordion-toggle[aria-expanded="true"]:after {
/* symbol for "opening" panels */
content: "\e113";
}
.panel-heading-one .accordion-toggle[aria-expanded="false"]:after {
/* symbol for "collapsed" panels */
content: "\e114";
}
And it will work perfectly.
Extra: In your accordion you have used same href='#collapseThree'
for last and second last item. When you will click on last element, it
will open second last item. So change your href in last element.

Cannot bottom align image in jumbotron

I'm trying to bottom align an img in a jumbotron, but cannot figure it out.
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-lg-8">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="col-lg-4 text-center">
<img src="http://via.placeholder.com/200x200">
</div>
</div>
</div>
</div>
I tried adding the following to the CSS
.vertical-bottom {
display: flex;
align-items: bottom;
}
And then added the additional class to the DIV containing the img
<div class="col-lg-4 text-center vertical-bottom">
This didn't work, why is it so hard to vertically align things in bootstrap?
Here a kind of code:
Bootply
Css:
The media query is set to 1200 because I see you're using col-lg-xx
#media screen and (min-width:1200px) {
.flex_container img{
object-fit: contain;
object-position: 100% 100%;
}
.flex_container {
display: flex;
}
}
Html:
<div class="jumbotron">
<div class="container">
<div class="row flex_container">
<div class="col-lg-8">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="col-lg-4 text-center flex_container">
<img src="http://via.placeholder.com/200x200" style="">
</div>
</div>
</div>
</div>

Redux-Form (V6) & Materialize.css 's Radio Button not working

I am having trouble combining with Redux-Form and Materialize.css's radio button.
Because of the syntax issue ( I believe label is the cause of it), if I combine both, it stops working (meaning that I cannot select any of the radio buttons).
If I take out the materialize.css, Redux-Form works properly.
Is it possible to combine both of these?
Here's a snippet of the code:
render() {
const { chartData, chartOptions } = this.state;
const { handleSubmit, submitting } = this.props
return (
<main className="welcome container">
<div className="row">
<div className="col center-align s12">
<h3>Title of the Poll</h3>
</div>
</div>
<BarChart data={chartData} options={chartOptions}/>
<form onSubmit={handleSubmit(this.onSubmit.bind(this))}>
<div className="row">
<div className="col s12">
<p>
<Field name="category" component="input" type="radio" value="male"/>
<label>Male</label>
</p>
<p>
<Field name="category" component="input" type="radio" value="female"/>
<label>Female</label>
</p>
</div>
<div className="col input-field s12">
<button className="btn waves-effect waves-light" type="submit" name="action">Submit
<i className="fa fa-paper-plane-o"></i>
</button>
</div>
</div>
</form>
</main>
)
}
Looking at CSS, it looked like by Materialze.css default, the html's input radio button has a left property of 99px which goes away from the screen.
Knowing that, I had to just insert a custom CSS on my own to move the input and align it above the radio button that materilize renders.
Here's what I came up with:
css
.radio-button-css{
position: relative !important;
z-index: 12;
// opacity: 1 !important;
left: 18px !important;
}
Notice I've inserted radio-button-css inside the Field attribute
<div className="row">
<div className="col s12">
<p>
<Field name="category" component="input" type="radio" className="radio-button-css" value="male"/>
<label>Male</label>
</p>
<p>
<Field name="category" component="input" type="radio" className="radio-button-css" value="female"/>
<label>Female</label>
</p>
</div>
<div className="col input-field s12">
<button className="btn waves-effect waves-light" type="submit" name="action">Submit
<i className="fa fa-paper-plane-o"></i>
</button>
</div>
</div>
From there, adjust the left property in the radio-button-css and after you are finish, set the opacity back to zero ( you need to set one to actual see the html's radio button)