A slide puzzle is to divide a picture into equal parts, scramble the order (below), and then slide it together into a complete picture.
To achieve a jigsaw puzzle, you need to consider how to randomly shuffle the order, how to exchange the location of two pictures, and so on. However, after using the Flexbox layout, this does not need you to consider, the browser will help you do, Flexbox is so powerful.
This article will share with you the code that uses javascript and Flexbox to implement a simple slide puzzle game. although it does not provide complete functions, we recommend it to you, if you like it, you can continue to complete the Slide Puzzle by dividing an image into several equal parts, disrupt the order (), and then slide it together to form a complete picture.
To implement a puzzle game, you need to consider how to randomly disrupt the o
CSS Flexbox Elastic Box modelSet the element style to Display:flex or Display:inline-flex, which makes the element a flex container, so that its child elements can be laid out in flex mode.Flex-direction:Value Row | Row-reverse | Column | Column-reverseDefault Value rowFlex-wrap:Value NoWrap | Wrap | Wrap-reverseDefault Value nowrapFlex-flow:Value Default Value Row nowrapFlex Sub-object distribution justify-content:Value Flex-start | Flex-end | Center
Flexbox is a very good and novel layout, so there are many compatibility issues. Flexbox's normative work has been done for many years, and different browsers do not agree on the level of implementation of different versions. However, the general can be divided into the old version and the new version of two versions (mixed version only support IE10, not considered), for these two versions of the support can be referred toMore detailed compatibility c
should be set to at least 33.33%, so the width value should be between 33.33% and 50% (assuming that the child element has no margin and other properties that make it "bigger")D. Suppose we set min-width:35%, (1) Then if two sub-elements a, b,a content of the same row is greater than or equal to 65% width, when the content of B exceeds 35% width, the latter element is squeezed to the next line, (2) if the contents of two child elements A and b,a on the same line are small, But since it is at le
Note: Today, when using Swiper.js to do the product carousel, encountered in the use of Flexbox under the premise of the child element set flex:1; All child elements are squeezed in the first phase (not executed to swipe);The reason is because there is no setting:flex-shrink property.Flex-shrink:Default value : 1applies to : Flex subkeyInheritance : NoneAnimation : YesCalculated value : Specify a valueValue:
defines the shrinkage ratio u
Line-height and Vertical-align are simple CSS properties, so that most people think they know how these two properties work. But in fact these two properties are very complex, perhaps the most difficult two properties of CSS, because these two properties and CSS in a little-known feature is closely Related: inline format context (IFC), this article and you share CSS Line-height and The use of vertical-align
CSS Learning (22nd)-flexbox model 3I. theory:1. flex-line-pack stack scaling rowA. Use the same as flex-packB. Add stretch start/end/center/justify (average distribution)/distribute (Half Space on both ends)/stretch (stretch to fill the entire container)C. flex-line for individuals, and flex-line-pack for groups
Ii. Practice:
1.
Title box1 box2 box3 box4 box5 box6 box7 box8
CSS Learning (21)-flexbox Model 2I. theory:1. flex-flowA. flex-direction: Set the scaling flow direction of the scaling containerB. flex-wrap: Set whether the scaling items in the scaling container are lined up with lines when the scaling container does not have enough space.2. flex-packA. parameters with the same attributes as box-packB. The distribute scaling project is evenly distributed in the same row.C. the starting edge of the first scaling pro
One, proportional attribute flex and layout direction Properties FlexdirectionFor example, the Flex property values for three views are 2, 4, 8, respectively, and their height ratio is 2:4:8. , the width is not specified, and the default is full screen width.class Zlfreactnativedemo extends Component {render () {return ( ); }}const Styles=stylesheet.create ({container: {flex:1,Flexdirection: column , BackgroundColor:' #00FFFF ',}, Style1: {flex:2, BackgroundColor:' Red ',}, Style2: {fle
); }}ConstStyles1 =stylesheet.create ({container: {//Note: The height of the parent view is determined with the child view//change the direction of the spindleFlexdirection:'Row', BackgroundColor:'Purple', //distance from top of spaceMarginTop: -, //Setting the alignment of the spindleJustifycontent:'Center', //to set the alignment of the side axisAlignitems:'Flex-end', //set image wrapping display, default is no line breakFlexwrap:'Wrap', //determines the width of the box widt
First, the theory:1.flex-flowA.flex-direction setting the telescopic flow direction of the telescopic containerB.flex-wrap setting a scaling item in a telescopic container if there is not enough space in the telescopic container, whether the scaling item is wrapped in a telescopic container2.flex-packA. With the same parameters as the Box-pack propertyB.distribute scaling items are evenly distributed across the same lineThe starting edge of the first telescopic project in the C.start telescopic
First, in the React Native Flexbox has
Flex:1 its child elements have the same length
Justifycontent Vertical Layout
Alignitems Horizontal Layout
Flexdirction row (Landscape) Colum (portrait) Overall direction
Justifycontent (The relationship between child elements and child elements) Flex-start Center Flex-end space-around Space-between Sub-
Alignitems determines the position of your control in the vertical left or right of the screen Flex-start (lef
line-heightand vertical-align in CSS is a two simple property. So simple, most people believe they have a full understanding of how they work and how to use them. But in fact it's not so. They are complex and one of the most difficult aspects of CSS and one of the features of CSS: inline formatting context (inline formatting contexts).For example, you can set a line-height value with a length unit or a value without a unit, but its default value is no
1. Leverage FlexParentelement{display:flex;justify-content:space-between;}Align left aligned to right div class = "Justifyspan" > span > align span > span > align span > div > { display: -webkit-box; display: -ms-flexbox; display: -webkit-flex; d
Object alignment I have a coup.
When making courseware, it is often necessary to align some objects. Only by feeling, using the mouse drag or 4 arrow keys, it is difficult to achieve the precise alignment of multiple objects. To avoid "horseshoes striking difference", you can use the following methods:
Method One: Use grid and drawing guides to assist in aligning
1, click the right mouse button in the blank of the slide, click the "Grid and Guide"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.