I have a form I'm building with 3 text inputs on the same row, however one of the descriptions takes 2 lines vs 1 line for the others. This is leading to the input boxes below not being aligned.
I tried adding carriage returns & line breaks special chars to the text input so that the text would start one row lower, but it's not working.
Ends up looking like this ... but I want my input rows aligned.
bla bla bla
bla bla bla
bla bla bla
bla bla bla
Input
Input
Input
Tried the following but not working
msrp = cols[2].text_input("\n\r MSRP")
Any way to add line breaks to the texts so that I can get my input boxes below aligned or some other way to force it?
use cell_renderer to make line break (\n,\t ...) change to <br> take effect.
only test on show data, may not take effect on edit field
from st_aggrid import AgGrid, GridOptionsBuilder, JsCode
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_default_column(
editable=True, wrapText=True, autoHeight=True // here is the key point
)
cell_renderer = JsCode("""
function(params) {
return params.value.replaceAll("\\n","<br>"); // here is the key point
}
""")
gb.configure_column('hash_code', cellRenderer=cell_renderer,maxWidth=200)
gbb = gb.build()
AgGrid(df, gbb, height=1000, allow_unsafe_jscode=True, theme='blue')
more detail :
https://ag-grid.com/javascript-data-grid/row-height/
https://www.ag-grid.com/javascript-data-grid/component-cell-renderer/
.grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr;
align-items: end;
}
.col {
padding: 15px;
}
<div class="grid">
<div class="row">
<div class="col">
<label>blá blá blá blá blá blá blá blá blá blá blá blá blá blá blá</label>
<input asp-for="First_Name_AR" class="form-control" />
</div>
</div>
<div class="row">
<div class="col">
<label>blá blá blá</label>
<input asp-for="Second_Name_AR" class="form-control" />
</div>
</div>
<div class="row">
<div class="col">
<label>blá blá blá</label>
<input asp-for="Father_Name_AR" class="form-control" />
</div>
</div>
</div>
Related
I have kind of difficult css positioning for me and need help.
The problem is a have a row of div with flex-wrap: wrap. (picture 1)
Each div have 50% width so we have 2 columns.
I need each input of 2 element in row have to be on the the same position. (picture 2)
You can see that all element on the same label, independent of title's height and error's height.
I tried to use align-items: flex-start/end, but it doesn't work cause if you use start you depend on title's height and if you use flex-end then you depend on error's height. In both way moved on the different level.
I hope that I explained clear.
Can you tell me how I can achieve this behavior?
I tried to use different flex-items properties value, but it didn't work.
I would appreciate if you tell me how to place divs like on the picture 2.
I created a pen to demonstrate how this can be done with CSS Grid, but for those that want to see the code, here it is:
<form class="form">
<div class="form-group">
<label for="1">Input label</label>
<input id="1" type="text">
</div>
<div class="form-group">
<label for="2">Input label</label>
<input id="2" type="text">
<div>Some error, maybe long</div>
</div>
<div class="form-group">
<label for="3">Input label</label>
<input id="3" type="text">
</div>
<div class="form-group">
<label for="4">Input label</label>
<input id="4" type="text">
<div>A really, lreally looooooong error message that wraps onto multiple lines and may never happen in real life</div>
</div>
</div>
<div class="form-group">
<label for="5">Input label that is running onto multiple lines and is the root of the issue</label>
<input id="5" type="text">
<div>A really, lreally looooooong error message that wraps onto multiple lines and may never happen in real life</div>
</div>
<div class="form-group">
<label for="6">Input label</label>
<input id="6" type="text">
</div>
</form>
.form {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 1rem;
}
.form-group {
display: grid;
grid-template-rows: 1fr auto 1fr;
}
label {
font-weight: bold;
align-self: end;
}
The use of grid-template-rows, and not aligning elements using the grid container is the secret here.
How do I center the form inputs in this image? I'm using the GridLayout defined here: https://www.matblazor.com/LayoutGrid using form elements defined here https://www.matblazor.com/EditContext
This is my attempt but i must be missing something:
<div class="container login-layout mat">
<MatCard>
<MatCardContent>
<EditForm Model="Login" OnValidSubmit="Success">
<div class="mat-layout-grid">
<div class="mat-layout-grid-inner">
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-12">
<MatH2>Login</MatH2>
</div>
<div class="mx-auto
mat-layout-grid-cell
mat-layout-grid-cell-span-12">
<MatTextField ValidationDisabled="true" Label="Username" #bind-Value="Login.Username" />
<MatTextField ValidationDisabled="true" Type="Password" Label="Password" #bind-Value="Login.Username" />
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-12">
<MatButton class="float-right">Log in</MatButton>
#*<MatButton class="float-right" #onclick="OnLoginClick">Log in</MatButton>*#
</div>
</div>
</div>
</EditForm>
<div class="container">
<MatCaption>Need an account? </MatCaption>
<MatButton class="float-right aslkjd-c0ass" #onclick="OnSignUp">Sign up</MatButton>
</div>
</MatCardContent>
</MatCard>
</div>
mx-auto or say margin auto in x axis work in div if you provide it a width or max-width. try using it on input field itself or try giving div a width or you can use flex justify content: center and flex-direction: column on the div
I am using Karate and I am finding the way how to match value in deeply placed span.
I have this case:
...
<form action="#">
<div class="row">
<div class="col-lg-12">
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<div class="card-body">
<p>...</p>
<div class="form-group " style="display: grid; grid-template-rows: auto auto;">
<span>
<label for="title">Title</label>
<input name="title" id="title" class="form-control" placeholder="e.g. My MacBook Key" value="">
</span>
<span class="invalid-feedback">Title is required</span>
</div>
<div class="form-group " style="display: grid; grid-template-rows: auto auto;">
<span>
<label for="key">Key</label>
<textarea name="key" id="key" class="form-control" rows="12" placeholder="Typically starts with "ssh-rsa" or "ssh-ed25519""></textarea>
</span>
<span class="invalid-feedback">Key is required</span>
I need to check value of last span (using match) - last line (if "Key is required" is present in span).
I have tried some code variations but I was not successful. E.g.:
* match text('form/div/div/div/div:2/div:2/span:2') == 'Key is required'
or
* match text('{span:2}.invalid-feedback') == 'Key is required'
Any idea how to solve it without using full xpath?
Thank you.
There is a very easy way to do this:
* def messages = scriptAll('.invalid-feedback', '_.innerHTML')
* match messages[1] == 'Key is required'
This question already has answers here:
Div side by side without float
(6 answers)
Closed 6 years ago.
This code is layed out in 1 column. I want to get a tabular 2 column layout.
<span id="col1">
<div>Filter by</div>
<div>
<input type="text" value="hello" />
</div>
</span>
<span id="col2">
<div>Search</div>
<div>
<input type="text" value="hello" />
</div>
</span>
How can I achieve this without using float?
fiddle
You can use the flexbox for that:
.container {
display: flex;
}
<div class="container">
<div id="col1">
<div>Filter by</div>
<div>
<input type="text" value="hello" />
</div>
</div>
<div id="col2">
<div>Search</div>
<div>
<input type="text" value="hello" />
</div>
</div>
</div>
Note that I changed your span to div elements (since span are inline and should not contain block elements).
I also wrapped the entire block with div.container so I'll be able to set that container as the flexbox.
Assuming you want the columns to be able to be shown/hidden, you could do this:
<head>
<script>
$('.next').click(function() {
var next = $('.col').next();
var curr = $('.col');
next.addClass('col-active');
curr.removeClass('col-active');
});
</script>
<style>
.col {
display: none;
}
.col-active {
display: block !important;
}
</style>
</head>
<body>
<span id="col1" class="col col-active">
<div>Filter by</div>
<div>
<input type="text" value="hello" />
</div>
</span>
<span id="col2" class="col">
<div>Search</div>
<div>
<input type="text" value="hello" />
</div>
</span>
<a class="next">Next Page</a>
</body>
This essentially shows and hides the columns based on the <a> being clicked. I use this quite a lot when having sliders/tabulated pages.
Hope this helps :)
The margin takes only affect for the first line (after automatic line break (depends on the size) will be ignored).
The HTML:
<div class="BWForm_form-group">
<div class="col-md-3 BWTextLeft">
<label class="control-label" for="ContactPersonName">Name des Ansprechpartners<span style="color:red; display: inline-block;"> *</span></label>
</div>
<div class="col-md-5">
<div class="col-md-12">
<input class="text-box single-line input-validation-error" data-val="true" data-val-required="The Name of contact person field is required." id="ContactPersonName" name="ContactPersonName" value="" type="text">
</div>
</div>
<div class="col-md-4">
<span class="field-validation-error" data-valmsg-for="ContactPersonName" data-valmsg-replace="true"><span class="" for="ContactPersonName">The Name of contact person field is required.</span></span>
</div>
</div>
The css:
.field-validation-error {
color: #B94A48;
font-weight: bold;
margin: 15px;
}
The "BWForm_form-group" is inherited by the bootstrap class form-group."BWTextLeft" will only align:left.
What can I do to fix it ?
It looks like that click (the problem is right to my green arrow and vertical line)
Ty for helping
oh ok remove the margin left from field-validation-error and then add a new class like to the container
<div class="col-md-12 custom">
and the css looks like the below
custom {
margin:15px;
}
demo example here
if you dont want to mess with the margins of the col-md-12 then you should add a surrounding div like this
<div class="col-md-12">
<div class="custom">
<div class="field-validation-error">