How do I make a button span across 2 columns? - css

I'm working on a calculator app, and there are very specific things that I want for it. I want the colors of the buttons to vary and I want the "0" button to span across the two front columns so that the buttons beside it will be the same size as the rest. I think that just looks better. I have tried many things and none of them worked. I created my own button component and here is all the code that I think is necessary to show:
This is my App.js file
return (
<div className='App'>
<div className='calculator'>
<ResultBar />
<div className='row'>
<Button color="#625C5D" symbol="Clear" />
<Button color="#625C5D" symbol="+/-" />
<Button color="#625C5D" symbol="%" />
<Button color="#B04929" symbol="/" />
</div>
<div className='row'>
<Button symbol="7" />
<Button symbol="8" />
<Button symbol="9" />
<Button color="#B04929" symbol="x" />
</div>
<div className='row'>
<Button symbol="4" />
<Button symbol="5" />
<Button symbol="6" />
<Button color="#B04929" symbol="-" />
</div>
<div className='row'>
<Button symbol="1" />
<Button symbol="2" />
<Button symbol="3" />
<Button color="#B04929" symbol="+" />
</div>
<div className='row'>
<Button style={{columnSpan: 2}} symbol="0"/>
<Button symbol="." />
<Button color="#B04929" symbol="=" />
</div>
{/* <div className='display'>
{result ? <span>({result})</span> : '0'}
</div> */}
{/* <div className='keyboard'>
</div> */}
</div>
</div>
);
This is my button component
import "./Button.css";
const Button = ({ symbol, color }) => {
return (
<div style={{ backgroundColor: color }} className="button-styles">
{symbol}
</div>
);
}
export default Button;
And here's the css for the button
.button-styles {
height: 4em;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(229, 143, 82);
color: white;
font-size: 24px;
flex: 1;
margin: 4px;
border-radius: 16px;
}
At first I tried making a classname called button-span-two and added the line
grid-column: span 2;
Then I tried adding a property like symbol and color in the button component to add to the styles that would represent the number of columns to span. I tried using both gridColumn and columnSpan for this. Then I tried making a separate component with its own css file called ButtonSpan that would basically be the same as my button component but with a grid-column property set to 1/3. None of these worked. The calculator stayed the same with each try.

Related

VUE - QUASAR - TIPTAP - How to Set CSS Height on Editor's Inner Element

How can I get the inner editor portion (which is highlighted with a thin blue line) to go full height. This is the internal element that gets created by the tiptap editor:
<div contenteditable="true" tabindex="0" class="ProseMirror" spellcheck="false"> Editable content goes here./div>
UPDATE:
I manually added the classes ('col' and 'column') in the rendered output and now it works the way I want it to. Is there a way to do this without having to reach into the class property of the element?
<div contenteditable="true" tabindex="0" class="ProseMirror col column" spellcheck="false"> Content Here </div>
Here is the component code I am using in my quasar example app. I have tried umpteen different variations of classes in the divs around the editor. Nothing I do seems to affect the resulting "contenteditable" div container above.
<template>
<q-page class="column justify-start">
<div class="column col absolute-full bg-secondary">
<div class="col column editor">
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">
<div class="menubar">
<button
class="menubar__button"
:class="{ 'is-active': isActive.bold() }"
#click="commands.bold"
>
<icon name="bold" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.italic() }"
#click="commands.italic"
>
<icon name="italic" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.strike() }"
#click="commands.strike"
>
<icon name="strike" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.underline() }"
#click="commands.underline"
>
<icon name="underline" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.code() }"
#click="commands.code"
>
<icon name="code" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.paragraph() }"
#click="commands.paragraph"
>
<icon name="paragraph" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 1 }) }"
#click="commands.heading({ level: 1 })"
>
H1
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 2 }) }"
#click="commands.heading({ level: 2 })"
>
H2
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 3 }) }"
#click="commands.heading({ level: 3 })"
>
H3
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.bullet_list() }"
#click="commands.bullet_list"
>
<icon name="ul" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.ordered_list() }"
#click="commands.ordered_list"
>
<icon name="ol" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.blockquote() }"
#click="commands.blockquote"
>
<icon name="quote" />
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.code_block() }"
#click="commands.code_block"
>
<icon name="code" />
</button>
<button
class="menubar__button"
#click="commands.horizontal_rule"
>
<icon name="hr" />
</button>
<button
class="menubar__button"
#click="commands.undo"
>
<icon name="undo" />
</button>
<button
class="menubar__button"
#click="commands.redo"
>
<icon name="redo" />
</button>
</div>
</editor-menu-bar>
<editor-content class="col column editor__content" :editor="editor" />
</div>
</div>
</q-page>
</template>
<script>
import Icon from 'components/Icon'
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import {
Blockquote,
CodeBlock,
HardBreak,
Heading,
HorizontalRule,
OrderedList,
BulletList,
ListItem,
TodoItem,
TodoList,
Bold,
Code,
Italic,
Link,
Strike,
Underline,
History
} from 'tiptap-extensions'
export default {
components: {
EditorContent,
EditorMenuBar,
Icon
},
data () {
return {
editor: new Editor({
extensions: [
new Blockquote(),
new BulletList(),
new CodeBlock(),
new HardBreak(),
new Heading({ levels: [1, 2, 3] }),
new HorizontalRule(),
new ListItem(),
new OrderedList(),
new TodoItem(),
new TodoList(),
new Link(),
new Bold(),
new Code(),
new Italic(),
new Strike(),
new Underline(),
new History()
],
content: `
<h2>
Hi there,
</h2>
<p>
this is a very <em>basic</em> example of tiptap.
</p>
<pre><code>body { display: none; }</code></pre>
<ul>
<li>
A regular list
</li>
<li>
With regular items
</li>
</ul>
<blockquote>
It's amazing đź‘Ź
<br />
– mom
</blockquote>
`
})
}
},
beforeDestroy () {
this.editor.destroy()
}
}
</script>
<style>
</style>
I have been learning about Vue.js & Quasar UI toolset. I want to use the TIPTAP WYSIWYG editor component (available here: https://github.com/scrumpy/tiptap). I am fine with their examples, I can get the component to load and work fine. But for the life of me, I cannot figure out how to get the inner editing part (which gets outlined in blue when you click on it) to go 'Full Height' from the outset.
I have tried everything I can think of and searched and searched for some sort of example. The editor expands (grows) fine when you add content, but for some reason, I can't get it to start at full height-- which I'll note the example doesn't illustrate either.
What am I not doing?
Try writing this on css
/* remove outline */
.ProseMirror:focus {
outline: none;
}
/* set */
.ProseMirror {
min-height: 100px;
max-height: 100px;
overflow: scroll;
}

Form input-field is too small using Materialize-CSS

I have a Login form for a basic Admin Portal, however the input-field itself to click on is extremely small. The bar itself seems to be the entire size of the clickable input-field, so you can't click the label whatsoever to enter.
Code as follows:
<div className="container">
<form onSubmit={handleSubmit} className="white">
<h5 className="center">Cars4U Administration</h5>
<div className="input-field">
<input type="text" name="username" className="validate" required onChange={handleChange} />
<label htmlFor="username">Username</label>
</div>
<div className="input-field">
<input type="password" name="password" className="validate" required onChange={handleChange} />
<label htmlFor="password">Password</label>
</div>
<div className="input-field center">
<button className='btn z-depth-0' type='submit'>Login</button>
</div>
</form>
</div>
If my cursor is in the following position, I am unable to click the input-field. I am only able to click it directly on the line:
CSS:
form {
background-color: white;
margin-top: 80px;
margin-left: 350px;
margin-right: 350px;
border-radius: 3px;
}
form label {
padding-left: 40px;
padding-right: 40px;
padding-top: 20px;
font-weight: 700;
}
form .input-field {
padding-left: 40px;
padding-right: 40px;
padding-top: 20px;
}
According to Anthony's suggestion, you're supposed to have both name and id as identifiers.
Add id to your input -
<input name="username"/> to <input name="username"id="username"/>
class App extends React.Component {
render() {
return (
<div className="container">
<form className="white">
<h5 className="center">Cars4U Administration</h5>
<div className="row">
<div className="input-field">
<input type="text" id="username" className="validate" required />
<label htmlFor="username">Username</label>
</div>
<div className="input-field">
<input
type="password"
id="password"
className="validate"
required
/>
<label htmlFor="password">Password</label>
</div>
</div>
<div className="input-field center">
<button className="btn z-depth-0" type="submit">
Login
</button>
</div>
</form>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById("root"));
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="root"></div>

Buttons in Bootstrap (3) are getting rendered without any default padding when using React

I'm currently learning React and I'm trying to render some buttons in my app. However, when they're rendered in the page they all show all grouped together and without the default margin.
Image of buttons rendered without default margin using React
I'm unable to reproduce this problem when I render a static HTML version:
Image of buttons rendered with default margin using HTML only
I'm not sure at all how to troubleshoot this and I would like to be able to use Bootstrap in React without having to add my own CSS.
In case it helps, the exact same thing happened some time ago when I tried to append the same buttons using jQuery before starting to learn React. I was unable to fix it back then as well.
React code:
import React, { Component } from 'react';
class Container extends Component {
render() {
return(
<div className="container">
<div className="panel panel-default question">
<Title/>
<Body/>
</div>
</div>
)
};
};
class Title extends Component {
render() {
return(
<div className="panel-heading">
<h3 className="panel-title">Panel Title</h3>
</div>
);
};
};
class Body extends Component {
render() {
return(
<div className="panel-body">
<p className="panel-question">Question Content</p>
<textarea className="form-control" rows="5" id="comment"></textarea>
<div >
<OptionList/>
</div>
</div>
);
};
};
class OptionList extends Component {
render() {
return(
<div className="button-container text-center">
<button type="button" className="btn btn-primary">Option 1</button>
<button type="button" className="btn btn-primary">Option 2</button>
<button type="button" className="btn btn-primary">Option 3</button>
<button type="button" className="btn btn-primary">Option 4</button>
<button type="button" className="btn btn-primary">Option 5</button>
</div>
);
};
};
export default Container;
HTML Only:
<div class="container">
<div class="panel panel-default question">
<div class="panel-heading">
<h3 class="panel-title">Panel Title</h3>
</div>
<div class="panel-body">
<p class="panel-question">Question Content</p>
<textarea class="form-control" rows="5"></textarea>
<div >
<div class="button-container text-center" id="button-container">
<button type="button" class="btn btn-primary">Option 1</button>
<button type="button" class="btn btn-primary">Option 2</button>
<button type="button" class="btn btn-primary">Option 3</button>
<button type="button" class="btn btn-primary">Option 4</button>
<button type="button" class="btn btn-primary">Option 5</button>
</div>
</div>
</div>
</div>
</div>
Does anyone know how to overcome this issue? Will this happen with other React elements as well? Thanks for the help and any feedback you may have!
Edit:
I'm not using any custom CSS but the app is using the default CSS from create-react-app:
App.css
.App {
text-align: center;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}
.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
}
.App-title {
font-size: 1.5em;
}
.App-intro {
font-size: large;
}
#keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
index.css
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}

Styling multiple POST actions as a Bootstrap button group

I have multiple "POST" buttons (empty forms with a single submit button) to handle some actions which have side-effects. I need to make these buttons appear as a Bootstrap button group (.btn-group) as if they were a tags with a .btn class applied.
My first idea was to reproduce all the css styles Bootstrap uses for .btn-groups but with a form child element instead of .btn. Well it turns out there are a lot of styles involved! I'm hoping there's another solution. I included the very first basic style needed to have buttons in a single line in the snippet. Many more styles are needed to manage the borders, rounded corners, etc.
.btn-group.try1 > form {
position: relative;
float: left;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<h1>Doesn't work</h1>
<div class="btn-group">
<form method="post" action"./action1">
<button type="submit" class="btn btn-danger">Action with side-effect 1</button>
</form>
<form method="post" action"./action2">
<button type="submit" class="btn btn-default">Action with side-effect 2</button>
</form>
<form method="post" action"./action3">
<button type="submit" class="btn btn-warning">Action with side-effect 3</button>
</form>
</div>
<h1>Desired appearance</h1>
<div class="btn-group">
Action with side-effect 1
Action with side-effect 2
Action with side-effect 3
</div>
<h1>Attempt 1</h1>
<div class="btn-group try1">
<form method="post" action"./action1">
<button type="submit" class="btn btn-danger">Action with side-effect 1</button>
</form>
<form method="post" action"./action2">
<button type="submit" class="btn btn-default">Action with side-effect 2</button>
</form>
<form method="post" action"./action3">
<button type="submit" class="btn btn-warning">Action with side-effect 3</button>
</form>
</div>
Why do I use forms?
actions with side-effects should use POST.
I'd rather not use javascript to POST where vanilla HTML works just fine.
You can create a class modifier and use it with bootstrap's .form-group class.
.form-group--flex {
display: flex;
flex-wrap: wrap;
}
.form-group--flex button {
border-radius: 0;
}
Then for the border-radius you can use pseudo-selectors.
.form-group--flex form:first-of-type button {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.form-group--flex form:last-of-type button {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
Code Snippet:
.form-group--flex {
display: flex;
flex-wrap: wrap;
}
.form-group--flex button {
border-radius: 0;
}
.form-group--flex form:first-of-type button {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.form-group--flex form:last-of-type button {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="form-group form-group--flex">
<form method="post" action "./action1">
<button type="submit" class="btn btn-danger">Action with side-effect 1</button>
</form>
<form method="post" action "./action2">
<button type="submit" class="btn btn-default">Action with side-effect 2</button>
</form>
<form method="post" action "./action3">
<button type="submit" class="btn btn-warning">Action with side-effect 3</button>
</form>
</div>
Notes:
The only thing that bootstrap's class .form-group does is add a margin bottom.
.form-group {
margin-bottom: 15px;
}

Background image resize by itself

I'm a little bit desesparate, i have tried multiple things and nothing is working. So my issue is the following :
Everytime i click on a input field, the background resize by himself, i have a blank space on the bottom and on the top.
I have added :
cordova.plugins.Keyboard.disableScroll(true);
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.disableScroll(true);
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
login.html
<ion-view view-title="Login" align-title="left">
<ion-content class="background">
<div class="hero no-header flat">
<div class="content" style="bottom: 0px;">
<div class="app-icon"></div>
<h1 style="text-transform: uppercase;">App</h1>
</div>
</div>
<div class="list padding" style="margin-top: 25px;">
<label style="margin-bottom: 20px; display: block;">
<input type="text" placeholder="Adresse e-mail" ng-model="data.email" class="customInput">
</label>
<label style="margin-bottom: 20px; display: block;">
<input type="password" placeholder="Mot de passe" ng-model="data.password" class="customInput">
</label>
</div>
<div class="button-bar padding">
<button class="button button-small button-border icon-left ion-social-google button-assertive-900" ng-click="login(data)">Connexion</button>
<button class="button button-small button-border icon-left ion-social-facebook button-positive-900">Facebook</button>
</div>
<div class="padding">
<button class="button button-full button-register ink" ui-sref="app.register">Créer votre compte</button>
</div>
</ion-content>
.background.scroll-content {
background: url('../img/login.jpg') no-repeat;
background-size: cover;
background-position: center;
margin: auto;
z-index: 2;
}
The issue is that when the keyboard is shown the background resizes or the keyboard pushes the background image up.
Hmm, please explain better. I've tried your code here: http://play.ionic.io/app/e9abbb2a5670 but I dont se anything wrong.

Resources