HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!-- tell angular this is flexboxDemoApp -->
<html lang="en" ng-app="flexboxDemoApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Игровая площадка Flexbox из CSS3 </title>
<!-- Angulars Material CSS -->
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular-material.min.css">
<!-- include our compiled CSS -->
<link href="css/style.css" rel="stylesheet">
</head>
<!-- this will be the only controller AppCtrl -->
<body ng-controller="AppCtrl">
<!-- Here's the main container -->
<md-content class="md-padding">
<div layout-gt-md="row" layout="column">
<div flex-gt-md="66" flex="100" class="right-padding">
<h3>Ширина дочерних элементов</h3>
<div layout="row" layout-align="center center" class="code">
<div flex="15">width: {{children_width}}%</div>
<md-slider flex min="0" max="100" ng-model="children_width" aria-label="width"></md-slider>
</div>
<md-divider></md-divider>
<h3>Свойства родительского flex-элемента – <span class="highlight">flex-контейнер</span></h3>
<div layout="column" layout-gt-md="row" class="code">
<div layout="row">
<div flex>
<strong>flex-direction</strong>
<md-radio-group ng-model="parent.flexDirection">
<md-radio-button value="row" class="highlight">row</md-radio-button>
<md-radio-button value="row-reverse">row-reverse</md-radio-button>
<md-radio-button value="column">column</md-radio-button>
<md-radio-button value="column-reverse">column-reverse</md-radio-button>
</md-radio-group>
</div>
<div flex>
<strong>flex-wrap</strong>
<md-radio-group ng-model="parent.flexWrap">
<md-radio-button value="nowrap" class="highlight">nowrap</md-radio-button>
<md-radio-button value="wrap">wrap</md-radio-button>
<md-radio-button value="wrap-reverse">wrap-reverse</md-radio-button>
</md-radio-group>
</div>
</div>
<div layout="row">
<div flex>
<strong>justify-content</strong>
<md-radio-group ng-model="parent.justifyContent">
<md-radio-button value="flex-start" class="highlight">flex-start</md-radio-button>
<md-radio-button value="flex-end">flex-end</md-radio-button>
<md-radio-button value="center">center</md-radio-button>
<md-radio-button value="space-between">space-between</md-radio-button>
<md-radio-button value="space-around">space-around</md-radio-button>
</md-radio-group>
</div>
<div flex>
<strong>align-items</strong>
<md-radio-group ng-model="parent.alignItems">
<md-radio-button value="stretch" class="highlight">stretch</md-radio-button>
<md-radio-button value="flex-start">flex-start</md-radio-button>
<md-radio-button value="flex-end">flex-end</md-radio-button>
<md-radio-button value="center">center</md-radio-button>
<md-radio-button value="baseline">baseline</md-radio-button>
</md-radio-group>
</div>
</div>
<div layout="row">
<div flex>
<strong>align-content</strong>
<md-radio-group ng-model="parent.alignContent">
<md-radio-button value="stretch" class="highlight">stretch</md-radio-button>
<md-radio-button value="flex-start">flex-start</md-radio-button>
<md-radio-button value="flex-end">flex-end</md-radio-button>
<md-radio-button value="center">center</md-radio-button>
<md-radio-button value="space-between">space-between</md-radio-button>
<md-radio-button value="space-around">space-around</md-radio-button>
</md-radio-group>
</div>
</div>
</div>
<small>* Значение свойства по умолчанию <span class="highlight">подсвечены</span>.</small>
<md-divider></md-divider>
<h3>Свойства дочерних элементов – <span class="highlight">flex-элементы</span></h3>
<div>
<p>Свойства дочерних flex-элементов могут быть применены на дочернем уровне, раздельно для каждого элемента. Смотрите раздел с результатами и изменяйте какие-нибудь из их свойств. Наведите указатель мыши или коснитесь поля, чтобы увидеть название свойства.</p>
</div>
<md-divider hide show-sm show-md></md-divider>
</div>
<div flex>
<h3 class="pull-left">Результат</h3>
<p class="pull-right">
<md-button class="md-accent md-raised" ng-click="addChild()">Добавить дочерний элемент</md-button>
</p>
<div class="clearfix"></div>
<div
class="flexbox-parent"
ng-attr-style="
-webkit-flex-direction: {{parent.flexDirection}};
flex-direction: {{parent.flexDirection}};
-webkit-flex-wrap: {{parent.flexWrap}};
flex-wrap: {{parent.flexWrap}};
-webkit-justify-content: {{parent.justifyContent}};
justify-content: {{parent.justifyContent}};
-webkit-align-items: {{parent.alignItems}};
align-items: {{parent.alignItems}};
-webkit-align-content: {{parent.alignContent}};
align-content: {{parent.alignContent}};
"
>
<div
class="code md-whiteframe-z1"
ng-repeat="child in children"
ng-attr-style="
width: {{children_width}}%;
-webkit-order: {{child.order}};
order: {{child.order}};
-webkit-flex-grow: {{child.flexGrow}};
flex-grow: {{child.flexGrow}};
-webkit-flex-shrink: {{child.flexShrink}};
flex-shrink: {{child.flexShrink}};
-webkit-flex-basis: {{child.flexBasis}};
flex-basis: {{child.flexBasis}};
-webkit-align-self: {{child.alignSelf}};
align-self: {{child.alignSelf}};
"
>
<div class="clearfix">
<span class="child-number" aria-label="Number">{{$index + 1}}</span>
<span class="remove-child pull-right" ng-click="removeChild($index)" title="Remove">
✖
</span>
</div>
<div class="child-controls">
<md-input-container>
<md-tooltip md-direction="top">order</md-tooltip>
<input type="number" ng-model="children[$index].order">
</md-input-container>
<md-input-container>
<md-tooltip md-direction="top">flex-grow</md-tooltip>
<input type="number" ng-model="children[$index].flexGrow">
</md-input-container>
<md-input-container>
<md-tooltip md-direction="top">flex-shrink</md-tooltip>
<input type="number" ng-model="children[$index].flexShrink">
</md-input-container>
<md-input-container>
<md-tooltip md-direction="top">flex-basis</md-tooltip>
<input type="text" ng-model="children[$index].flexBasis">
</md-input-container>
<md-input-container>
<md-tooltip md-direction="top">align-self</md-tooltip>
<md-select ng-model="children[$index].alignSelf">
<md-option ng-value="value" ng-repeat="value in ['auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch']">{{value}}</md-option>
</md-select>
</md-input-container>
</div>
</div>
</div>
</div>
</div>
</md-content>
<!-- AngularJS -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-aria.min.js"></script>
<!-- Angular Material JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular-material.min.js"></script>
<!-- App.js -->
<script src="js/app.js"></script>
</body>
</html>
@import "compass/css3";
@import "compass";
// Flex container
.flexbox-parent {
@include display-flex;
background: #FFD54F;
overflow: hidden;
width: 100%;
padding: 3px;
min-height: 550px;
max-height: 1000px;
// Flex items
> div {
display: inline-block;
background: white;
overflow: hidden;
margin: 3px;
padding: 5px;
.child-controls {
margin-top: 7px;
}
}
}
.child-number {
display: block;
width: 22px;
height: 22px;
background: #FFB300;
color: white;
font-size: 14px;
font-weight: bold;
padding-top: 3px;
text-align: center;
@include border-radius(50%);
float: left;
}
.code {
font-family: Consolas, "Courier New", Monospace;
font-size: 15px;
}
.remove-child {
background: transparent;
color: #FF6F00;
font-size: 14px;
cursor: pointer;
}
.highlight {
color: #FF8F00;
}
.pull-left {
float: left;
}
.pull-right {
float: right;
}
.clearfix {
&:after {
content: '';
display: block;
clear: both;
}
}
.right-padding {
padding-right: 15px;
}
h3 {
margin: 0 0 10px 0 !important;
}
p {
margin: 0 0 10px 0 !important;
line-height: 1.4em !important;
}
md-input-container {
padding: 0 0 5px 0 !important;
.md-input {
padding: 0 !important;
line-height: 1em !important;
}
}
md-select {
margin-top: 0 !important;
.md-select-label {
padding-top: 2px !important;
padding-bottom: 4px !important;
}
}
md-radio-button {
margin: 5px 10px !important;
}
md-divider {
margin: 10px 0 !important;
}
// Declare the flexboxDemoApp module and its dependency 'ngMaterial'
var app = angular.module('flexboxDemoApp', ['ngMaterial']);
// Declare the AppCtrl controller
app
.config(['$mdThemingProvider', function ($mdThemingProvider) {
$mdThemingProvider
.theme('default')
.accentPalette('amber', {
default: '700'
});
}])
.controller('AppCtrl', ['$scope', function ($scope) {
$scope.parent = {
flexDirection: 'row',
flexWrap: 'nowrap',
justifyContent: 'flex-start',
alignItems: 'stretch',
alignContent: 'stretch'
};
$scope.children_width = 12; // %
$scope.children = [];
var addChild = function (order, flexGrow, flexShrink, flexBasis, alignSelf) {
$scope.children.push({
order: order || 0,
flexGrow: flexGrow || 0,
flexShrink: flexShrink || 1,
flexBasis: flexBasis || 'auto',
alignSelf: alignSelf || 'auto'
});
};
var removeChild = function (index) {
$scope.children.splice(index, 1);
};
$scope.addChild = addChild;
$scope.removeChild = removeChild;
for (var i = 0; i < 5; i++) {
addChild();
}
}]);
Also see: Tab Triggers