Giter VIP home page Giter VIP logo

absoluteposition's Introduction

Absolute Position

Absolute Position it's a position library, created for positional elements on the screen in an extremely easy way.

Running

for running , you just need to put the cdn script tag into your project.:

<script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>

Source

The Full Source Code it's available in:
Source

Basic Hello World

these it's the example of a simple div

Page of The Following Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>

</head>
<body>
        <div  APosition="$16:9(50px,100px,200px,300px)" style="background-color: red;">

            Hello World
        </div>
</body>
</html>

Understanding the Args

Every time you type and APosition inside what ever tag , its became recognizable by the lib after you pass the following arguments:

Example:

    <div  APosition=" $16:9         (50px, 100px,200px, 300px)">
                      AspectRatio    Left, Top  ,Width, Height

Measures

you can use px,%,vh,vw as the measures (I will add more on the future)

Operators

With the Operators + and - you can determine positions dynamically on the screen

Putting a div next to each other on Horizontal

Page of The Following Code

As you can See the + operator increments 100px the value left of each div

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>

</head>
<body>
<div  APosition="$16:9(00px,100px,100px,100px)" style="background-color: red;"></div>
<div  APosition="$16:9(+10px,100px,100px,100px)" style="background-color: blue;"></div>
<div  APosition="$16:9(+10px,100px,100px,100px)" style="background-color: red;"></div>
<div  APosition="$16:9(+10px,100px,100px,100px)" style="background-color: blue;"></div>

</body>
</html>

Putting a div next to each other on Vertical

Page of The Following Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>

</head>
<body>
<div  APosition="$16:9(0px,00px,100px,100px)" style="background-color: red;"></div>
<div  APosition="$16:9(0px,+10px,100px,100px)" style="background-color: blue;"></div>
<div  APosition="$16:9(0px,+10px,100px,100px)" style="background-color: red;"></div>
<div  APosition="$16:9(0px,+10px,100px,100px)" style="background-color: blue;"></div>

</body>
</html>

Putting a div next to each other on Horizontal from right to left

you also can put divs from button to the top or from right to the left by using the - operators

Page of The Following Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>

</head>
<body>
<div  APosition="$16:9(800px,100px,100px,100px)" style="background-color: red;"></div>
<div  APosition="$16:9(-10px,100px,100px,100px)" style="background-color: blue;"></div>
<div  APosition="$16:9(-10px,100px,100px,100px)" style="background-color: red;"></div>
<div  APosition="$16:9(-10px,100px,100px,100px)" style="background-color: blue;"></div>



</body>
</html>

Centralizing Elements

With the % prop, you can centralize or position an element in every part you want

Horizontal Centralization

Page of The Following Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>

</head>
<body>
        <div  APosition="$16:9(200px,200px,200px,200px)" style="background-color: red;">
            <div  APosition="$16:9(0%,33.3%,100%,33.3%)" style="background-color: blue;">
            </div>

        </div>
</body>
</html>

Vertical Centralization

Page of The Following Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>

</head>
<body>
        <div  APosition="$16:9(200px,200px,200px,200px)" style="background-color: red;">
            <div  APosition="$16:9(33.3%,0%,33.3%,100%)" style="background-color: blue;">
            </div>

        </div>
</body>
</html>

Full Centralization

Page of The Following Code

Macros

With Macros, you can define macros to replace the code into the tag these it's useful when you want to avoid code repetition

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>
</head>
<body>

<script>APosition_define_macro("test","+100px,100px,100px,100px")</script>

<div  APosition="$16:9(00px,100px,100px,100px)" style="background-color: red;"></div>
<div  APosition="$16:9(test)" style="background-color: blue;"></div>
<div  APosition="$16:9(test)" style="background-color: red;"></div>
<div  APosition="$16:9(test)" style="background-color: blue;"></div>

</body>
</html>

Page of The Following Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>

</head>
<body>
        <div  APosition="$16:9(200px,200px,200px,200px)" style="background-color: red;">
            <div  APosition="$16:9(33.3%,33.3%,33.3%,33.3%)" style="background-color: #0033ff;">
            </div>

        </div>
</body>
</html>

Error Handling

if some error happen on some tag it will be showed on console

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>
</head>
<body>
        <div  APosition="$16:9ddpx,100px,200px,300px)" style="background-color: red;">

            Hello World
        </div>
</body>
</html>

Page of The Following Code

Disabling error Logs

if you want to disable error logs , you just need to set the variable absolute_position_show_errors to false

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/gh/OUIsolutions/AbsolutePosition@main/versions/AbsolutePosition_v0.66.js"></script>
</head>
<body>

        <script>
            absolute_position_show_errors = false;
        </script>

        <div  APosition="$16:9ddpx,100px,200px,300px)" style="background-color: red;">

            Hello World
        </div>
</body>
</html>

Page of The Following Code

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.