I have this basic form
<div class="card mb-5 card-central-responsive" style="min-height: 579px;">
<div class="card-body">
<form #apkCreationForm="ngForm" class="mt-2" novalidate (ngSubmit)="onSubmitApk()">
<div role="alert" class="mb-& ng-star-inserted" style="padding-bottom: .10rem" ng-reflect-ng-class="">
<h4 class="alert-heading">{{ 'apk.product-description' | translate }}</h4>
</div>
<div class="row">
<div class="col-6">
<label class="form-group has-float-label">
<input class="form-control" required ngModel #name="ngModel" name="name" [(ngModel)]="apkName"/>
<span>{{ 'apk.name' | translate }}</span>
<div *ngIf="!name.valid && apkCreationForm.submitted" class="invalid-tooltip">{{ 'apk.name-required' | translate }}!</div>
</label>
</div>
<div class="col-6">
<label class="form-group has-float-label">
<ng-select
[items]="isFree"
bindLabel="id"
name="isFree"
bindValue="id"
[(ngModel)]="isFreeSelected">
</ng-select>
<span>{{ 'apk.is-free' | translate }}</span>
<div *ngIf="!isFreeSelected && apkCreationForm.submitted" class="invalid-tooltip">{{ 'apk.isfree-required' | translate }}</div>
</label>
</div>
</div>
</div>
</form >
</div>
</div>
I have to add a div image on top of this form to have something like this:
I tried many solutions without success. Please how could I achieve this ?
I use ng-bootstrap in my app
Thanks in advance
By applying Position absolute, you can align any object. I just wanted to show you the procedure you're going to do in a simple way.
body {
background-color: #121723;
}
.container {
margin-top: 200px;
}
.form-container {
background-color: #252A39;
color: #f1f1f1;
height: 30rem;
position: relative;
padding-top: 40px;
}
.image-container {
position: absolute;
top: -30%;
left: 5%;
width: 15rem;
height: 15rem;
background-color: #2E3446;
padding: 15px;
border-radius: 3px;
}
.bordered-div {
width: 100%;
height: 100%;
border: 3px dashed #121723;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="container">
<div class="form-container">
<!-- image-container -->
<div class="image-container">
<div class="bordered-div">
</div>
</div>
<!-- image-container end -->
<div class="row no-gutters form-tab">
<div class="col-md-2 offset-md-3">
<h6 class="text-capitalize text-right">product details</h6>
</div>
<div class="col-md-2">
<h6 class="text-capitalize text-right">graphic assets</h6>
</div>
<div class="col-md-2">
<h6 class="text-capitalize text-right">categorization</h6>
</div>
</div>
<div class="form-input">
<!-- İnputs -->
</div>
</div>
</div>
You could use about div's in css
position: absolute;
left: %10;
top: %10;
But when on the different pixels measurement, you should something css diversity.
Related
I want to place logo exactly linked linked below image (centered above div). How it can be this done using css? This template it is designed using tabler.io.
<div class="container-xl mt-3">
<div class="d-flex justify-content-center">
<div class="col-6">
<div class="card">
<div class="card-body">
<img src="{{ asset('backend/img/logo.png') }}" alt="{{ $settings->site_name }}" width="110" height="32" alt="Tabler" class="navbar-brand-image">
<div class="col-12 col-md-12 col-lg-12 col-sm-12">
<h3 class="card-title">{{ $plan_details->plan_name }}</h3>
<form action="{{route('stripe.payment.status', $paymentId )}}" method="post" id="payment-form">
#csrf
<div class="form-group">
<div class="mb-2">
<label for="card-element">
Please enter your credit card information
</label>
</div>
<div class="mb-4">
<div id="card-element" style="display: block; width: auto; padding: 0.52rem .75rem; font-size: 2rem; line-height: 1.4; color: #606060; background-color: #ffffff; background-clip: padding-box; border: 1px solid #ccced6; border-radius: .25rem; transition: border-color .20s ease-in-out,box-shadow .20s ease-in-out; box-shadow: rgb(0 0 0 / 24%) 0px 3px 8px;">
<!-- A Stripe Element will be inserted here. -->
</div>
<!-- Used to display form errors. -->
<div id="card-errors" class="text-danger" role="alert"></div>
<input type="hidden" name="plan" value="" />
</div>
</div>
<div class="">
<button
id="card-button"
class="btn btn-danger w-100"
type="submit"
data-secret="{{ $intent }}"
> {{ __('Pay Now') }} </button>
</div>
</form>
</div>
<br>
<a class="mt-2 text-muted text-underline text-center" href="{{route('stripe.payment.cancel', $paymentId )}}"><p>Cancel payment and back to home</p></a>
</div>
</div>
</div>
</div>
</div>
output of the above code it is linked below:
----CSS----
<style>
.center-elements{
display: flex;
flex-direction: column;
align-items: center;
}
.logo {
width: 100%;
float: left;
text-align: center;
}
.logo img {
position: absolute;
transform: translate(-50%, -50%);
}
</style>
----HTML----
<div class="center-elements">
<div class="logo">
<img src="myimage.png">
</div>
<div>Invoice from One Medical</div>
</div>
Use flex, but first you should have both the logo and the div inside one div tag.
Here you go:
<div class="center-elements">
<img src="logo.png" />
<div>
Invoice from One Medical
</div>
</div>
<style>
.center-elements{
display: flex;
flex-direction: column;
align-items: center;
}
</style>
I am trying to display the cards as input type is a checkbox, on selecting the cards I am able to fetch the details what are cards selected by the user, and my requirement is I required to highlight the card which is selected by the user.
for example, I need to highlight the card whose checkbox is checked, and if the checkbox is unchecked I need to show as the card.
lable+input[type=checkbox]:checked {
//some css code
}
<form [fromGropu]="form1">
<label for="{{i}}" *ngFor="let item of items" ;let i=index ">
<input type="checkbox " id="{{i}} " [value]="item " (change)="onchange() "/>
<div class="card rounded-0 ">
<div class="card-header ">{{item.header}}</div>
<diva class="card-body>{{item.desc}}</div>
<div class="card-footer">{{item.footer}}</div>
</div>
</div>
</label
</form>
but above CSS is not working, could anyone help on this
After input checked, the div.card following input should apply the css.
Your css should be like this
input[type=checkbox]:checked + div.card{
color: red;
}
Demo https://stackblitz.com/edit/angular-checked-input?file=src/app/app.component.css
Why not just highlight using a class which is toggled using ngClass? please try this change.
<form>
<label for="{{i}}" *ngFor="let item of items;let i =index" (click)="item.active = !item.active;"
[ngClass]="item.active ? 'active' : ''" style="display:block;">
<div class="card rounded-0">
<div class="card-header">{{item.header}}</div>
<div class="card-body">{{item.desc}}</div>
<div class="card-footer">{{item.footer}}</div>
</div>
</label>
</form>
Note: please delete this active property for the array used if you are sending the data to any API. Below is a working example!
Stack Blitz Demo
.services input[type="checkbox"] {
display: none;
}
.services label {
height: 100%;
padding: 10px;
margin: 0px;
border-radius: 0.55rem;
}
.services input[type="checkbox"]:checked + label {
background: #20df80;
}
.services input[type="checkbox"]:checked + label::after {
font-family: "Font Awesome 5 Free";
font-weight: 900;
border: 2px solid #1dc973;
content: "\f00c";
font-size: 24px;
position: absolute;
top: -25px;
left: 50%;
transform: translateX(-50%);
height: 50px;
width: 50px;
line-height: 50px;
text-align: center;
border-radius: 50%;
background: white;
}
.services img{
max-width: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class='container mt-5'>
<div class="row services">
<div class="col-4 col-sm-4 col-md-3 col-lg-3 mb-5 d-flex justify-content-star">
<div class="card shadow-soft text-center" style="width: 100%;">
<input class="" type="checkbox" id="24 Horas" name="type[]" value="5" checked>
<label for="24 Horas">
<br>
<h5 class="card-title"><strong>24 Horas</strong></h5>
<img src="https://icon-library.com/images/icon-img/icon-img-29.jpg" alt="">
</label>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-lg-3 mb-5 d-flex justify-content-star">
<div class="card shadow-soft text-center" style="width: 100%;">
<input class="" type="checkbox" id="Aire acondicionado" name="type[]" value="4">
<label for="Aire acondicionado">
<br>
<h5 class="card-title"><strong>Aire acondicionado</strong></h5>
<img src="https://icon-library.com/images/icon-img/icon-img-29.jpg" alt="">
</label>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-lg-3 mb-5 d-flex justify-content-star">
<div class="card shadow-soft text-center" style="width: 100%;">
<input class="" type="checkbox" id="Bar" name="type[]" value="8">
<label for="Bar">
<br>
<h5 class="card-title"><strong>Bar</strong></h5>
<img src="https://icon-library.com/images/icon-img/icon-img-29.jpg" alt="">
</label>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-lg-3 mb-5 d-flex justify-content-star">
<div class="card shadow-soft text-center" style="width: 100%;">
<input class="" type="checkbox" id="Buffet" name="type[]" value="3" checked>
<label for="Buffet">
<br>
<h5 class="card-title"><strong>Buffet</strong></h5>
<img src="https://icon-library.com/images/icon-img/icon-img-29.jpg" alt="">
</label>
</div>
</div>
</div>
</div>
I am trying to align the text "address" in left div vertically. But i am unable to.
Here is the code,
div.row {
border: 1px solid black;
padding: 10px;
}
.centre {
display: block;
text-align: center;
vertical-align: middle;
background: yellow;
height: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-md-3 centre">
<label>Address</label>
</div>
<div class="col-md-6">
<div class="row">
<!--nested row one-->
<div class="col-md-6">
<label>Street</label>
</div>
<div class="col-md-6">
<input name="stname">
</div>
</div>
<div class="row">
<!--nested row two-->
<div class="col-md-6">
<label>Landmark</label>
</div>
<div class="col-md-6">
<input name="lmark">
</div>
</div>
<div class="row">
<!--nested row three-->
<div class="col-md-6">
<label>Zip code</label>
</div>
<div class="col-md-6">
<input name="zipcode">
</div>
</div>
</div>
</div>
<!--row end-->
</div>
What am i doing wrong. I am using bootsrap 3.
Plunker: https://plnkr.co/edit/cu4ZJVSp3jYTyBwz4NKB?p=preview (View Plunker in full screen)
I am trying to have result similar to this. The coloured borders are only for representation .
You are setting the styles to the center div, instead it should be the label inside the center div
<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="script.js"></script>
<style>
div.row div{
border: 1px solid black;
padding: 10px;
}
.centre label{
display: block;
text-align: center;
vertical-align: middle;
background: yellow;
height: 100%;
padding:5px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-3 centre">
<label>Address</label>
</div>
<div class="col-md-6">
<div class="row"><!--nested row one-->
<div class="col-md-6">
<label>Street</label>
</div>
<div class="col-md-6">
<input name="stname">
</div>
</div>
<div class="row"><!--nested row two-->
<div class="col-md-6">
<label>Landmark</label>
</div>
<div class="col-md-6">
<input name="lmark">
</div>
</div>
<div class="row"><!--nested row three-->
<div class="col-md-6">
<label>Zip code</label>
</div>
<div class="col-md-6">
<input name="zipcode">
</div>
</div>
</div>
</div><!--row end-->
</div>
</body>
</html>
you can add this code in your CSS file to get vertical-align.
but first, you have to add a new class with row class
<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="script.js"></script>
<style>
.vertical > div {
display: table-cell;
vertical-align: middle;
float: none;
}
.vertical > div {
display: table-cell;
vertical-align: middle;
float: none;
}
div.row div{
border: 1px solid black;
padding: 10px;
}
.centre label{
display: block;
text-align: center;
vertical-align: middle;
background: yellow;
height: 100%;
padding:5px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row vertical">
<div class="col-md-3 centre">
<label>Address</label>
</div>
<div class="col-md-6">
<div class="row"><!--nested row one-->
<div class="col-md-6">
<label>Street</label>
</div>
<div class="col-md-6">
<input name="stname">
</div>
</div>
<div class="row"><!--nested row two-->
<div class="col-md-6">
<label>Landmark</label>
</div>
<div class="col-md-6">
<input name="lmark">
</div>
</div>
<div class="row"><!--nested row three-->
<div class="col-md-6">
<label>Zip code</label>
</div>
<div class="col-md-6">
<input name="zipcode">
</div>
</div>
</div>
</div><!--row end-->
</div>
</body>
</html>
Here's a solution setting top margin/padding on columns not nested then cancelling top margin/padding in nested ones:
Plunkr
Relevant CSS:
[class*="col-"] {
border: 1px solid black;
padding: 10px;
}
.row:first-child [class*="col-"] {
margin-top: 10px;
background-color: lightgreen;
}
.row .row:first-child [class*="col-"] {
margin-top: -10px;
background-color: pink;
}
.row .row:not(:first-child) [class*="col-"] {
margin-top: 0;
background-color: lightblue;
}
Solution by #codegeek which avoids these problems is better imho :)
Code Pen
You can remove the offset and match it up to 12-grid system.
div.row {
border: 1px solid black;
padding: 10px;
}
.centre {
background: yellow;
top: 60px;
border: 1px solid blue;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-3 centre">
<label>Address</label>
</div>
<div class="col-xs-8 col-sm-offset-1" style="border:1px solid green">
<!--You can remove style and remove offset and change it to sm-9 -->
<div class="row">
<!--nested row one-->
<div class="col-xs-6">
<label>Street</label>
</div>
<div class="col-xs-6">
<input name="stname">
</div>
</div>
<div class="row">
<!--nested row two-->
<div class="col-xs-6">
<label>Landmark</label>
</div>
<div class="col-xs-6">
<input name="lmark">
</div>
</div>
<div class="row">
<!--nested row three-->
<div class="col-xs-6">
<label>Zip code</label>
</div>
<div class="col-xs-6">
<input name="zipcode">
</div>
</div>
</div>
</div>
<!--row end-->
</div>
As for now, margin-top is a worth option trying.
I positioned the left div by using top: 50%(takes the height of the parent) and then using translateY, which takes the height of the current element.
Since relative positioning didnt take % values, I have used absolute.
But giving absolute makes the div come out of the document flow, hence used "left" for the right sibling with the width of the left sibling.
.parent{
position: relative;
}
.centre{
background: yellow;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.right{
left: 25%;
/* width of left sibling, since col-md-3 is 25%*/
background: lightgreen;
}
Plnkr Link(with bootstrap) or JsFiddle (without Bootstrap)
Result:
Your vertical-align:middle doesn't work, because elements with display: block cannot be centered that way. An easy alternative would be to use display: flex.
Here is a snippet to demonstrate the way display:flex can be used to center pretty much everything:
div.row div{
border: 1px solid black;
padding: 10px;
}
.centre{
display: block;
text-align: center;
vertical-align: middle;
background: yellow;
height: 100%;
}
.flex {
display: flex;
align-items: center;
}
<div class="container-fluid">
<div class="row">
<div class="flex">
<div class="col-md-3 centre">
<label>Address</label>
</div>
<div class="col-md-6">
<div class="row"><!--nested row one-->
<div class="col-md-6">
<label>Street</label>
</div>
<div class="col-md-6">
<input name="stname">
</div>
</div>
<div class="row"><!--nested row two-->
<div class="col-md-6">
<label>Landmark</label>
</div>
<div class="col-md-6">
<input name="lmark">
</div>
</div>
<div class="row"><!--nested row three-->
<div class="col-md-6">
<label>Zip code</label>
</div>
<div class="col-md-6">
<input name="zipcode">
</div>
</div>
</div>
</div>
</div><!--row end-->
</div>
EDIT: maybe this guide might be of interest for you:
Centering in CSS: A Complete Guide
I'm new in this community and I have a basic english, but I hope to make me understand. I just started studying Angular 2 and my question is this:
I have created a keyboard and above there are 4 span each of which must contain a digit that will be clicked on the keyboard. Each time one of these keys is pressed (each key is a div) I would like that number to be displayed in one of these span, but I do not know how to do it. Also after pressing 4 numbers (and then filling the span) I would like the text above the span changes to another.
HTML:
<div class="container-fluid fixed-heading">
<div class="back-button">
<img src="/assets/images/icon_arrow_left.png" (click)="back()" />
</div>
<app-main-app-header [heading]="'SETTINGS.SECURITY.PIN.HEADING'">{{"SETTINGS.SECURITY.PIN.HEADING"|translate}}</app-main-app-header>
</div>
<div class="container-fluid component">
<div class="row pin text-center">
<div>
<span>Here I would like to have the text</span>
</div>
<div class="container-fluid">
<div class="col-xs-3">
<span></span>
<div class="line"></div>
</div>
<div class="col-xs-3">
<span></span>
<div class="line"></div>
</div>
<div class="col-xs-3">
<span></span>
<div class="line"></div>
</div>
<div class="col-xs-3">
<span></span>
<div class="line"></div>
</div>
</div>
</div>
<div class="row text-center">
<div class="col-xs-4 cursor-pointer">
<span>1</span>
<p> </p>
</div>
<div class="col-xs-4 cursor-pointer">
<span>2</span>
<p>ABC</p>
</div>
<div class="col-xs-4 no-border-right cursor-pointer">
<span>3</span>
<p>DEF</p>
</div>
</div>
<div class="row text-center">
<div class="col-xs-4 cursor-pointer">
<span>4</span>
<p>GHI</p>
</div>
<div class="col-xs-4 cursor-pointer">
<span>5</span>
<p>JKL</p>
</div>
<div class="col-xs-4 no-border-right cursor-pointer">
<span>6</span>
<p>MNO</p>
</div>
</div>
<div class="row text-center">
<div class="col-xs-4 cursor-pointer">
<span>7</span>
<p>PQRS</p>
</div>
<div class="col-xs-4 cursor-pointer">
<span>8</span>
<p>TUV</p>
</div>
<div class="col-xs-4 no-border-right cursor-pointer">
<span>9</span>
<p>WXYZ</p>
</div>
</div>
<div class="row text-center" id="no-border">
<div class="col-xs-4 bg-color cursor-pointer">
<span> .</span>
</div>
<div class="col-xs-4 cursor-pointer">
<span>0</span>
</div>
<div class="col-xs-4 no-border-right bg-color cursor-pointer">
<span class="glyphicon glyphicon-remove-sign"></span>
</div>
</div>
</div>
CSS:
.fixed-heading{
left: 0; /* Left edge at left for now */
right: 0; /* Right edge at right for now, so full width */
margin: auto;
max-width: 375px;
position: fixed;
width: 100%;
z-index: 25;
border-bottom: 1px inset seashell;
}
.back-button{
cursor:pointer;
position: absolute;
top: 9px;
}
.pin{
background-color: #f2f2f2;
height: 300px;
}
.row{
border-bottom: 1px inset;
padding-bottom: -2px;
font-size: xx-large;
}
.row.pin{
border-bottom: none;
border-right: none;
font-size: small;
padding: 80px;
}
p{
font-size: small;
margin-top: -8px;
}
.col-xs-4{
border-right: 1px inset;
}
#no-border{
border-bottom: none;
}
.no-border-right{
border-right: none;
}
.bg-color{
background-color: #f2f2f2;
}
.line{
border: 2px solid grey;
width: 25px;
}
.row.pin span{
margin-left: 8px;
}
.glyphicon.glyphicon-remove-sign{
margin-top: 5px;
}
I'm using Bootstrap 3.3.7 and Angular 4.2.2.
If I understand you correctly, you want to create something like a PIN code input. If that's correct, I think the best approach would have been to use keyboard input, and leveraging angular's built-in functionality described here.
However, to answer your question, one approach would be the following:
// In your component
public textThatChanges = 'previous text';
public input: string = '';
click(numberClicked: string) {
if (this.input.length < 4) {
this.input += numberClicked;
}
else if (this.input.length === 4) {
this.textThatChanges = 'new text';
}
}
// In the template
<!-- This is the span that changes after 4 clicks -->
<span>{{ textThatChanges }}</span>
<!-- As requested - 4 different elements, each displaying 1 digit -->
<span>{{ input.charAt(0) }}</span>
<span>{{ input.charAt(1) }}</span>
<span>{{ input.charAt(2) }}</span>
<span>{{ input.charAt(3) }}</span>
<!-- Do the following for each of the divs that can be clicked -->
<div (click)="click('1')"><span>1</span></div>
<div (click)="click('2')"><span>2</span></div>
Hello, i'm kinda new at css/bootstrap, i'm learning actually.
In this case, i will probably need to add some css at "chat_funcs" div, but i don't know what to write to get what i want.
The problem:
What i want is:
My code so far:
HTML:
<div id="chat" class="col-md-3 col-xs-12">
<span class="titulo">Chat</span>
<div class="msg">Mensagem teste</div>
<div class="msg">Mensagem teste</div>
<div class="msg">Mensagem teste</div>
</div>
<div id="chat_funcs" class="pull-right col-md-3 col-xs-12">
<div class="pull-left">
<input class="form-control" type="text">
<input class="btn btn-default" type="button" value="Enviar">
</div>
</div>
CSS:
#chat {
background-color: red ;
overflow: scroll;
overflow-x: hidden;
height: 80%;
position: absolute;
right: 0;
display: inline-block;
}
In order to achieve this you are going to use additional html div container. There're other ways too, but this one came to my mind first.
Here is html markup:
<div id="chat-container" class="col-md-3 col-xs-12">
<div class="row">
<div id="chat" class="col-md-12 col-xs-12">
<span class="titulo">Chat</span>
<div class="msg">Mensagem teste</div>
<div class="msg">Mensagem teste</div>
<div class="msg">Mensagem teste</div>
</div>
</div>
<div class="row">
<div id="chat_funcs" class="col-md-12 col-xs-12">
<div class="pull-left">
<input id="message-text" class="form-control" type="text"><br/>
<input class="btn btn-default" type="button" value="Enviar">
</div>
</div>
</div>
</div>
and here is css:
#chat-container{
position: absolute;
right: 0;
width: 160px;
}
#chat {
background-color: red ;
overflow: scroll;
overflow-x: hidden;
height: 80%;
width: 100%;
display: inline-block;
}
#message-text{
width: 140px;
}
here is a fiddle
I hope this helps