bootstrap col jumping out of container - css

I am working on a single page app using AngularJS. I scaffolded my project using yeoman's angular generator, I'm using bootstrap-sass-official and compass.
I have some angular ng-repeat generated content which I placed inside bootstrap's col-xs-4 divs. There are three divs in a single row, and the third one (the one that contains a phone number), spills over the edge of it's container. I don't know why that happens and how to fix it.
my html:
<div class="panel-heading">kontakt</div>
<div class="panel-content contact">
<div class="container" ng-repeat="contact in contacts">
<div class="col-xs-4">
<p class="name-text">{{ contact.name }}</p>
</div>
<div class="col-xs-4">
<p class="email-text">
<a href="mailto:{{ contact.email }}">
<span class="glyphicon glyphicon-envelope email-icon"></span>
<span class="email-sign">{{contact.email}}</span>
</a>
</p>
</div>
<div class="col-xs-4">
<p class="phone-text">
<span class="glyphicon glyphicon-phone-alt phone-icon"></span>
<span class="phone-sign">{{ contact.phone }}</span>
</p>
</div>
</div>
</div>
my css:
/********************************
PANELS
********************************/
.panel-heading {
background-color: $secondary-color;
text-align: center;
font-weight: 600;
font-size: 1.2em;
margin: 0;
padding: 0.5em;
#include breakpoint(desktop) {
border-radius: 10px;
}
}
.panel-content {
background-color: #fff;
margin: 0 2.5%;
padding: 1em 0;
font-size: 1.2em;
/********************************
SPECIFIC PANELS STYLES-LOCATION
********************************/
&.location {
p {
text-align: center;
margin: 0 0 1em 0;
}
.map-container {
background-color: red;
margin: 0 auto;
width: 80%;
height: 10em;
#include breakpoint(tablet) {
height: 15em;
}
#include breakpoint(desktop) {
height: 20em;
}
}
}
/********************************
SPECIFIC PANELS STYLES-CONTACT
********************************/
&.contact {
p {
margin: 0;
padding: 0;
&.email-text {
margin: 0 auto;
}
}
.phone-text {
text-align: right;
}
.email-sign, .phone-sign {
font-size: 0.7em;
#include breakpoint(tablet) {
font-size: 1em;
}
}
.email-icon, .phone-icon {
color: #fff;
background-color: $secondary-color;
padding: 0.5em;
border-radius: 90px;
}
}
/********************************
SPECIFIC PANELS STYLES-HOURS
********************************/
&.delovni-cas {
text-align: center;
}
}
my controller:
'use strict';
angular.module('angularApp')
.controller('LandingController', function ($scope) {
$scope.contacts = [
{
name: 'informacije:',
email: 'knjiznica#ijs.si',
phone: '+386 01 4773 304'
},
{
name: 'izposoja:',
email: 'ill#ijs.si',
phone: '+386 01 4773 304'
},
{
name: 'bibliografije:',
email: 'branka.strancar#ijs.si',
phone: '+386 01 4773 247'
},
{
name: 'vodja knjižnice:',
email: 'luka.sustersic#ijs.si',
phone: '+386 01 4773 258'
}
];
});
I tried narrowing this down as much as I can. If you need more info, here is a github repo of the project (relevant files are in the app folder, under views there's landing.html, and under styles _landing.scss .

You need to wrap the col's inside a row.
<div class="panel-heading">kontakt</div>
<div class="panel-content contact">
<div class="container" ng-repeat="contact in contacts">
<div class="row">
<div class="col-xs-4">
<p class="name-text">{{ contact.name }}</p>
</div>
<div class="col-xs-4">
<p class="email-text">
<a href="mailto:{{ contact.email }}">
<span class="glyphicon glyphicon-envelope email-icon"></span>
<span class="email-sign">{{contact.email}}</span>
</a>
</p>
</div>
<div class="col-xs-4">
<p class="phone-text">
<span class="glyphicon glyphicon-phone-alt phone-icon"></span>
<span class="phone-sign">{{ contact.phone }}</span>
</p>
</div>
</div>
</div>
</div>

Related

CSS - How to make a dynamic bootstrap list scrollable

I have this code in my vue app
<form class="d-flex me-auto" id="searchBar">
<div class="input-group">
<input class="form-control" type="text" placeholder="Cerca professionista" #keyup="search" aria-label="Search" v-model="searchInput">
<button class="btn btn-outline-success" #click.prevent="search">
<i class="fa-solid fa-search"></i>
</button>
</div>
</form>
<div class="list-group" v-if="searchResults.length > 0" id="searchResultsList">
<a href="#" class="list-group-item list-group-item-action" v-for="(result, index) in searchResults" :key="index" id="searchResult" #click.prevent="showUserProfile(result.username)">
<div class="d-flex w-100 justify-content-between">
<p class="ps-2 me-auto mb-1">{{ result.name }} {{ result.surname }}</p>
<!-- <img :src="result.propicUrl" id="searchResultThumbnail"> -->
</div>
<small class="ps-2 me-auto">{{ result.category }}</small>
</a>
</div>
I will have a list that will contain the results of a search, since there are a lot of results, how I can make it scrollable? At the moment I have added this css rules but not working
<style lang="scss">
#menu {
height: 75px;
.navbar-brand {
padding-top: 0;
#logo {
width: 60px;
height: 60px;
}
}
#searchBar {
width: 420px;
}
#searchResultsList {
position: absolute;
top: 3.8em;
left: 5.4em;
width: 420px;
overflow-y: scroll;
#searchResult {
overflow-y: scroll;
#searchResultThumbnail {
height: 40px;
width: 40px;
border-radius: 50%;
}
}
}
}
</style>
You need to set either height or max-height to a value that results in a concrete size (e.g: 40vw, 200px, 20pt) for overflow-y: auto | scroll to have any effect.
Without setting the (max-)height, the element will grow to match the height of its children and will never display an active scrollbar.
Side note: considering the element has position: absolute, height: 100% will likely delegate the height request to the closest positioned ancestor but, again, you do need a positioned ancestor with a concrete height for overflow-y: auto | scroll to work.
Generic example:
Vue.createApp().mount('#app')
#app {
max-height: 100px;
overflow-y: auto;
border: 1px solid red;
}
<script src="https://unpkg.com/vue#next/dist/vue.global.prod.js"></script>
<div id="app">
<div v-for="n in 20">test</div>
</div>
Playground:
const { createApp, reactive, toRefs } = Vue;
createApp({
setup: () => ({
...toRefs(reactive({
setHeight: false,
setMaxHeight: true,
listLength: 20
}))
})
}).mount('#app')
#app {
display: flex;
}
#app>* {
flex: 0 0 50%;
}
.scroller {
overflow-y: auto;
border: 1px solid red;
}
.controls {
padding: 0 1rem;
display: flex;
flex-direction: column;
}
* {
box-sizing: border-box;
}
<script src="https://unpkg.com/vue#next/dist/vue.global.prod.js"></script>
<div id="app">
<div class="scroller" :style="{ height: setHeight ? '100px' : '', maxHeight: setMaxHeight ? '100px': ''}">
<div v-for="n in listLength">test</div>
</div>
<div class="controls">
<div>
Items: <input type="number" v-model="listLength">
</div>
<label>
<input v-model="setHeight" type="checkbox">
Set height
</label>
<label>
<input v-model="setMaxHeight" type="checkbox">
Set max height
</label>
</div>
</div>
The difference between setting height and max-height is that with height the element will have the specified height even when it doesn't have enough content to fill it, while with max-height, when you don't have enough content, the element will shrink all the way down to 0 (unless something else gives it a soft min-height: e.g: a flex container).

Two child components in parent div (flex row) always at the same height in angular 10

disclaimer: sorry if my answer is somwhere in stackoverflow... Did not find and starting being a little frustrating...
I'm working with Angular 10 and in my app.component.html, have this snippet :
<div class="chats">
<app-friend-chat *ngFor="let friend of friends" [inputFriend]="friend" (close)="closeChat($event)">
</app-friend-chat>
<app-friend-list (friend)="openChat($event)"></app-friend-list>
</div>
The component app-friend-chat is dynamic and at the started time of the site, there is no instances of it so only app-friend-list is display.
Here is the css of app.component.css :
app-friend-chat{
position: relative;
margin: 0 !important;
width: 50vh;
}
.chats{
position: absolute;
bottom: 0;
right: 5px;
z-index: 9999;
display: flex;
flex-direction: row;
}
The thing is app-friend-list's height is moving up to creation of a new app-chat-friend's instance.
When closing all app-chat-friend's instances, app-friend-list get height back to its first value.
I want my app-friend-list keep its height.
Here is app-friench-chat'html :
<div *ngIf="friend">
<div class="chatHead" fxLayout="row" fxLayoutGap="5px">
<p class="friend">{{ friend.name }}</p>
<span fxFlex="auto" (click)="minimize()"></span>
<p class="close" (click)="closeChat(friend.name)">X</p>
</div>
<div *ngIf="!mini">
<div id="messages-box">
<div *ngFor="let message of messages" class="message">
<div [ngClass]="classForParagraphe(message)" class="paragraphe"
[innerHTML]="sanitizer.bypassSecurityTrustHtml(message.message)">
</div>
<div *ngIf="user.name === message.user" class="trash">
<span class="far fa-trash-alt" (click)="deleteMessage(message)"></span>
</div>
</div>
</div>
<emoji-mart class="emoji-mart" *ngIf="isEmojiPickerVisible" (emojiSelect)="addEmoji($event)"></emoji-mart>
<div fxLayout="row" fxLayoutGap="15px">
<div class="container">
<input [(ngModel)]="message" type="text" #input (keyup)="enter($event)" />
<button (click)="isEmojiPickerVisible = !isEmojiPickerVisible;">😀</button>
</div>
<button (click)="sendMessage()">
<svg width="20px" height="20px" viewBox="0 0 24 24">
<path
d="M16.6915026,12.4744748 L3.50612381,13.2599618 C3.19218622,13.2599618 3.03521743,13.4170592 3.03521743,13.5741566 L1.15159189,20.0151496 C0.8376543,20.8006365 0.99,21.89 1.77946707,22.52 C2.41,22.99 3.50612381,23.1 4.13399899,22.8429026 L21.714504,14.0454487 C22.6563168,13.5741566 23.1272231,12.6315722 22.9702544,11.6889879 C22.8132856,11.0605983 22.3423792,10.4322088 21.714504,10.118014 L4.13399899,1.16346272 C3.34915502,0.9 2.40734225,1.00636533 1.77946707,1.4776575 C0.994623095,2.10604706 0.8376543,3.0486314 1.15159189,3.99121575 L3.03521743,10.4322088 C3.03521743,10.5893061 3.34915502,10.7464035 3.50612381,10.7464035 L16.6915026,11.5318905 C16.6915026,11.5318905 17.1624089,11.5318905 17.1624089,12.0031827 C17.1624089,12.4744748 16.6915026,12.4744748 16.6915026,12.4744748 Z">
</path>
</svg>
</button>
</div>
</div>
</div>
And css :
.chatHead {
background: rgb(210, 206, 206);
border-radius: 10px;
height: 5vh;
}
#messages-box {
height: 45vh;
background-color: white;
padding-left: 0;
overflow-y: scroll;
}
app-friend-list'html:
<div *ngIf="user && user.name !== undefined">
<h6 (click)="showList()">Discussions</h6>
<div class="list" *ngIf="show">
<ul *ngFor="let ami of user.amis">
<li (click)="addChat(ami)">{{ ami }}</li>
</ul>
</div>
</div>
app-friend-list'css:
h6{
padding: 10px;
border: solid 1px black;
height: 5.5vh;
}
ul {
padding-right: 20px;
}
li {
list-style: none;
cursor: pointer;
}
I give you only relevant code (according to me).
The other probleme I can't get ride of is that when clicking on chatHead of app-friend-chat for minimize, the component get same size of app-friend-list and so let empty space at the bottom which is very dirty (should get only size of head part)
Feel free to ask me any code I forgot to give you.

Vue Mazeletter background

I am trying to use Mazeletter to create a background for every page on an app that I am building. However, I haven't done anything like this before and I would like some help with this. I have a basic test component which works as the background, and I can successfully place elements over it.
However, I want to make this a little more dynamic. One the text should be dynamic (i.e. passed in via props) and there should be enough text to have the background for as much content is present on the page (this would also be dynamic).
Here is the test component that I am currently working with:
<template>
<div id="mz-background">
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
</div>
</template>
<script>
export default {
name: "UnderworldPattern",
};
</script>
<style scoped>
#mz-background {
z-index: 0;
position: fixed;
overflow: hidden;
width: 100vw;
height: 100vh;
}
.mz-text {
line-height: 89.5px;
font-family: "mazeletter-underworld"; // imported in project css
font-size: 90px;
z-index: 1;
color: #000000;
user-select: none;
text-align: left;
letter-spacing: -0.409091px;
}
</style>
If someone could help me out in making this more dynamic I would be very grateful
Thanks for your time
Maybe something like following:
Define long set of chars and set overflow: hidden; on #mz-background.
Add listener on created hook, to detect window resize and call method to calculate nr of lines depending on ˙font-size˙. Then in template loop over calculated nr of lines.(rough solution)
export default {
name: "UnderworldPattern",
data() {
return {
textToShow: 'ThisIsATestThisIsATestThisIsATestThisIsATestThisIsATestThisIsATestThisIsATestThisIsATest',
nrOfLines: 0
}
},
methods: {
getNrOfLines() {
this.nrOfLines = parseInt(document.documentElement.clientHeight / 90)
}
},
mounted() {
this.getNrOfLines()
},
created() {
window.addEventListener("resize", this.getNrOfLines);
},
unmounted() {
window.removeEventListener("resize", this.getNrOfLines);
},
};
#mz-background {
z-index: 0;
position: fixed;
overflow: hidden;
width: 100vw;
height: 100vh;
}
.mz-text {
line-height: 89.5px;
font-family: "mazeletter-underworld"; // imported in project css
font-size: 90px;
z-index: 1;
color: black;
user-select: none;
text-align: left;
letter-spacing: -0.409091px;
overflow: hidden;
margin: 0;
}
<div id="app">
<template>
<div id="mz-background">
<p class="mz-text" v-for="index in nrOfLines" :key="index">{{ textToShow }}</p>
</div>
</template>
</div>

Can't find div for styling (tranform zoom) in javascript script tag in shadow dom of polymer 2.0 element

I am creating a polymer 2.0 PWA / Website. I have a problem with accessing a div container (I wish to zoom in and zoom out the div based on a user input).
In shadow dom with template dom if I am not able to get the element in Javascript so that on user action (like button click or slider) movement I can zoom the div.
I tried document getElementsByClassName, shadowroot search. I can see in shadow dom that this div is present. just not able to access it in javascript function in Polymer.
var ele = document.getElementsByClassName('containerMap')[0]; //
returns null in console can't find the element in shadow Dom
var el = this.shadowRoot.querySelector('someid'); // returns
null in console also tried '#someid' still null
console.log('shadowRoot el = '+JSON.stringify(el));
var elx = document.getElementById('someid'); // returns null in
console
console.log('shadowRoot el = '+JSON.stringify(elx));
//var el = this.$.someid; // does not find the element
// tried this.$['#someid'] this.$$('#someid') // does not work
console.log(el);
Here's the full code (removed few unwanted code elements so that focus is on the problem in hand)
MyApp.html
<link rel="lazy-import" href="epicsprint-page.html">
<dom-module id="my-app">
<template is="dom-bind">
<style>
....
</style>
....
<app-header-layout >
<div style="float:left; width:100%;">
<div style="float:left; width:10%;">
<paper-icon-button id="menuElement" icon="icons:menu" drawer-toggle halign="left"></paper-icon-button>
</div>
</div>
<div fit class="content">
<!-- IRON PAGES MAIN CONTENT -->
<iron-pages
selected="[[page]]"
attr-for-selected="name"
fallback-selection="not-found-404"
role="main">
<epicsprint-page name="epicsprint-page" user="{{user}}"
signedin="{{signedIn}}" statusknown="{{statusKnown}}" >
</epicsprint-page>
.....
</div>
</app-header-layout>
</app-drawer-layout>
</template>
</template>
<script>
</script>
...
window.customElements.define(MyApp.is, MyApp);
</script>
</dom-module>
Element: epicspring-page.html
<dom-module id="epicsprint-page">
<template is="dom-bind">
<style include="shared-styles">
:host {
padding: 10px;
font-family:'Fira Sans', sans-serif;
}
a paper-button,
a:hover paper-button,
a:link paper-button,
a:active paper-button,
a:visited paper-button {
width: 20%;
height: 35px;
}
.page { overflow:auto; width: 90%; height: 100%; }
.containerMap { width:100%; background: grey; }
.error-content{
width: 80wh;
height: 300px;
overflow: auto;
align-items: center;
}
/*************/
.board­__sprint {
/*background: #5ba4cf;*/
position: absolute;
left: auto;
padding: 20px;
overflow-x: auto;
white-space: nowrap;
}
.list {
display: inline-block;
vertical-align: top;
/*background: #d2d7e5;*/
width: 300px;
padding: 1px;
}
.list-content {
max-height: 80%;
overflow-y: auto;
padding-right: 5px;
/*margin-right: -5px;*/
margin-bottom: 20px;
padding-bottom: 60px;
}
.list-name {
padding: 10px;
border: none;
background: transparent;
}
.add-ticket {
background: linear-gradient(to bottom, #61bd4f 0, #5aac44
100%);
color: white;
font-weight: bold;
border: none;
padding: 10px;
}
.ticket {
/*background: white;*/
flex: 0 0 auto;
margin: 5px;
width: 200px;
height: 70px;
align-items: center;
white-space: normal;
}
.ticket-title {
width: 100%;
padding: 20px;
}
/*********/
</style>
<iron-ajax
id="getEpicSprintMap"
method="GET"
url="{{url}}"
handle-as="json"
content-type="application/json"
on-response="handleResponseGetEpicSprintMap"
on-error="handleErrorGetEpicSprintMap"
last-response="{{mapsData}}"
last-error="{{lastError}}">
</iron-ajax>
<div style="width: 100%">
<div style="float:left;">
<div><h5></h5></div>
<paper-icon-button src="../images/icons/help-icon-png.png"
on-tap="showHelpDialog"></paper-icon-button>
</div>
<div style="float:right;">
<div><h5></h5></div>
<paper-icon-button src="../images/icons/support-icon-png.png"
on-tap="showHelpDialog"></paper-icon-button>
</div>
</div>
<template is="dom-if" if="[[signedin]]">
<template is="dom-if" if="[[mapsData.successFlag]]">
<div style="float: center;">
<h5 style="color: white; font-size: 12px; text-
align:left;"> </h5>
</div>
<div style="float: center; display: flex">
<iron-image src="../images/logo.png" preload
sizing="contain"
on-tap="reloadEpics" style="width:200px; height:200px;
margin:auto;" ></iron-image>
</div>
<div style="float: center;">
<h1 style="color: white" class="launchAmount">Epics &
Sprints</h1>
<h2 style="color: white" class="launchAmount">Number of
sprints that an Epic spans</h2>
</div>
<input id="test" min="1" max="1000" value='1000' step="1"
onchange="showVal(this.value)" type="range"/>
<div class="containerMap" id="someid">
<div class="page">
<div class="content">
<div class="board­__sprint">
<template is="dom-repeat" items="{{mapsData.data}}"
as="row">
<div class="list">
<div class="list­-content">
<div style="text-align: center;">
<iron-image class=""
src="../images/icons/epic-icon-png.png"
preload
sizing="contain"
style="width:50px; height:50px; margin-
left: 50px;" ></iron-image>
</div>
<div style="text-align: center;">
<h3 class="sprintTitle" style="color: white; font-
size: 15px;background: black; padding: 10px; margin-top: 5px;">
<b>Epic: </b>[[row.key]]
</h3>
<h3 class="sprintTitle" style="color: white; font-
size: 15px;background: black; padding: 10px; margin-top: 5px;">
[[row.title]]
</h3>
</div>
<template is="dom-repeat" items="{{row.sprint}}"
as="sprint">
<div class="ticket">
<paper-card style="float:center; width: 95%"
class$="{{_computedCardColorStories()}}">
<div style="width: 100%;">
<div style="float:left; width: 10%"
style$="{{getRandomInt(0, 20)}}">
<h7> </h7>
</div>
<div style="float:left; width: 90%; text-
align: center; padding: 10px;">
<h7 style="color: black; font-size:
18px; text-align:center;">[[sprint]]</h7>
</div>
</div>
</paper-card>
</div>
</template>
</div>
</div>
</template>
</div>
</div>
</div>
</div>
</template>
</template>
</template>
</template>
<script>
/**
* #polymer
* #extends HTMLElement
*/
class EpicSprintMapPage extends Polymer.Element {
static get is() { return 'epicsprint-page'; }
constructor() {
super();
}
ready() {
super.ready();
}
static get properties() {
return {
user: { type: Object, notify: true, readOnly: false, observer: '_userChanged' },
signedin: { type: Boolean, notify: true, readOnly: false, observer: '_signedinChanged' },
statusKnown: { type: Boolean, notify: true, readOnly: false, observer: '_statusChanged' },
localSettings : { type: Object, notify: true, readOnly: false },
mapsData: { type: Object, notify: true },
filterFromDate : { type: String, notify: true },
filterToDate: { type: String, notify: true },
defaultSprintVelocity: { type: Number, value: 0, notify: true },
zoomVal: { type: Number, value: 100, notify: true },
}
};
_userChanged(user){
this.user = user;
}
_signedinChanged(signedin){
this.signedin = signedin;
}
_statusChanged(statusKnown){
this.statusKnown = statusKnown;
}
showVal()
{
var zoomScale = Number(this.zoomVal)/100;
console.log('zoomScale = '+zoomScale);
var ele = document.getElementsByClassName('containerMap')[0]; // returns null in console can't find the element in shadow Dom
var el = this.shadowRoot.querySelector('someid'); // returns null in console also tried '#someid' still null
console.log('shadowRoot el = '+JSON.stringify(el));
var elx = document.getElementById('someid'); // returns null in console
console.log('shadowRoot el = '+JSON.stringify(elx));
//var el = this.$.someid; // doesn't find the element
// tried this.$['#someid'] this.$$('#someid')
console.log(el);
transformOrigin = [0,0];
el = el || instance.getContainer();
var p = ["webkit", "moz", "ms", "o"],
s = "scale(" + zoomScale + ")",
oString = (transformOrigin[0] * 100) + "% " + (transformOrigin[1] * 100) + "%";
for (var i = 0; i < p.length; i++) {
el.style[p[i] + "Transform"] = s;
el.style[p[i] + "TransformOrigin"] = oString;
}
el.style["transform"] = s;
el.style["transformOrigin"] = oString;
}
}//end Polymer
window.customElements.define(EpicSprintMapPage.is, EpicSprintMapPage);
</script>
</dom-module>
I am expecting I can find the element in shadow dom and be able to style the element and mimick zoom in out functionality by transforming the div.
I am not sure how to get the element and what syntax it should be.
Try to remove :
<template is="dom-bind">
...
</template>
You can use dom-bind template in index.html in order to binding without to defining new custome element. Then you can select your div element with this.shadowRoot...
For more information about dom-bind
EDİT
As there is some variable which I don't know the values, But keep in your mind that if dom-if statement is false then its content does not render. So, you can not access any element inside.

Align text box and textfield

I want to make a form for my react project. I have a text and it's corresponding text field against it. I tried using flexbox but I didn't do it right. This is my code
<div className="time-from-container">
<h4 style={styles.fontStyle}>From : </h4>
<TextField
id="time_in"
underlineFocusStyle={{borderColor: '#293C8E'}}
floatingLabelFocusStyle={{color: '#293C8E'}}
style={{width: 120}}
value={this.secondsToHms(this.props.new_marker_reducer.start)}
floatingLabelText="Start Time"
/>
</div>
<div className="time-to-container">
<h4 style={styles.fontStyle} >To :</h4>
<TextField
id="time_out"
underlineFocusStyle={{borderColor: '#293C8E'}}
floatingLabelFocusStyle={{color: '#293C8E'}}
style={{width: 120}}
value={this.secondsToHms(this.props.new_marker_reducer.end)}
floatingLabelText="End Time"
/>
</div>
I want to align then like this
How should I do it?
You can use flexbox and give the h4 a width
* {
margin: 0;
}
div {
display: flex;
margin: 0 0 1em;
align-items: center;
}
h4 {
width: 80px;
}
<div>
<h4>From: </h4>
<input type="text">
</div>
<div>
<h4>To: </h4>
<input type="text">
</div>
Or you can use the table display properties to mimic a table layout
* {
margin: 0;
}
.parent {
display: table;
}
.parent > div {
display: table-row;;
}
h4,input {
display: table-cell;
margin: 0 0 1em;
}
h4 {
padding-right: 1em;
}
<div class="parent">
<div>
<h4>From: </h4>
<input type="text">
</div>
<div>
<h4>To: </h4>
<input type="text">
</div>
</div>
.time-from-container h4, .time-to-container h4 {
display:inline-block;
width:90px;
}

Resources