I am working on this login/signup form on CodeIgniter. Got this login/signup code from the internet, but by default, it is in the center. So how do I move this form to the right side of the page? enter image description here
Login.html
JavaScript
x
100
100
1
<!DOCTYPE html>
2
<html >
3
<head>
4
<meta charset="UTF-8">
5
<title>Sign-Up/Login Form</title>
6
<link href='http://fonts.googleapis.com/css?family=Titillium+Web:400,300,600' rel='stylesheet' type='text/css'>
7
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
8
9
10
<link rel="stylesheet" href="<?php echo base_url('resources/style.css');?>">
11
12
13
</head>
14
15
<body>
16
<div class="form">
17
18
<ul class="tab-group">
19
<li class="tab active"><a href="#signup">Sign Up</a></li>
20
<li class="tab"><a href="#login">Log In</a></li>
21
</ul>
22
23
<div class="tab-content">
24
<div id="signup">
25
<h1>Sign Up for Free</h1>
26
27
<form action="/" method="post">
28
29
<div class="top-row">
30
<div class="field-wrap">
31
<label>
32
First Name<span class="req">*</span>
33
</label>
34
<input type="text" required autocomplete="off" />
35
</div>
36
37
<div class="field-wrap">
38
<label>
39
Last Name<span class="req">*</span>
40
</label>
41
<input type="text"required autocomplete="off"/>
42
</div>
43
</div>
44
45
<div class="field-wrap">
46
<label>
47
Email Address<span class="req">*</span>
48
</label>
49
<input type="email"required autocomplete="off"/>
50
</div>
51
52
<div class="field-wrap">
53
<label>
54
Set A Password<span class="req">*</span>
55
</label>
56
<input type="password"required autocomplete="off"/>
57
</div>
58
59
<button type="submit" class="button button-block">Get Started</button>
60
61
</form>
62
63
</div>
64
65
<div id="login">
66
<h1>Welcome Back!</h1>
67
68
<form action="/" method="post">
69
70
<div class="field-wrap">
71
<label>
72
Email Address<span class="req">*</span>
73
</label>
74
<input type="email"required autocomplete="off"/>
75
</div>
76
77
<div class="field-wrap">
78
<label>
79
Password<span class="req">*</span>
80
</label>
81
<input type="password"required autocomplete="off"/>
82
</div>
83
84
<p class="forgot"><a href="#">Forgot Password?</a></p>
85
86
<button class="button button-block">Log In</button>
87
88
</form>
89
90
</div>
91
92
</div><!-- tab-content -->
93
94
</div> <!-- /form -->
95
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
96
97
<script src="<?php echo base_url('resources/index.js');?>"></script>
98
99
</body>
100
</html>
Style.css
JavaScript
1
178
178
1
*, *:before, *:after {
2
box-sizing: border-box;
3
}
4
5
html {
6
overflow-y: scroll;
7
}
8
9
body {
10
background: #c1bdba;
11
font-family: 'Titillium Web', sans-serif;
12
}
13
14
a {
15
text-decoration: none;
16
color: #1ab188;
17
-webkit-transition: .5s ease;
18
transition: .5s ease;
19
}
20
a:hover {
21
color: #179b77;
22
}
23
24
.form {
25
background: rgba(19, 35, 47, 0.9);
26
padding: 40px;
27
max-width: 600px;
28
margin: 40px auto;
29
border-radius: 4px;
30
box-shadow: 0 4px 10px 4px rgba(19, 35, 47, 0.3);
31
}
32
33
.tab-group {
34
list-style: none;
35
padding: 0;
36
margin: 0 0 40px 0;
37
}
38
.tab-group:after {
39
content: "";
40
display: table;
41
clear: both;
42
}
43
.tab-group li a {
44
display: block;
45
text-decoration: none;
46
padding: 15px;
47
background: rgba(160, 179, 176, 0.25);
48
color: #a0b3b0;
49
font-size: 20px;
50
float: left;
51
width: 50%;
52
text-align: center;
53
cursor: pointer;
54
-webkit-transition: .5s ease;
55
transition: .5s ease;
56
}
57
.tab-group li a:hover {
58
background: #179b77;
59
color: #ffffff;
60
}
61
.tab-group .active a {
62
background: #1ab188;
63
color: #ffffff;
64
}
65
66
.tab-content > div:last-child {
67
display: none;
68
}
69
70
h1 {
71
text-align: center;
72
color: #ffffff;
73
font-weight: 300;
74
margin: 0 0 40px;
75
}
76
77
label {
78
position: absolute;
79
-webkit-transform: translateY(6px);
80
transform: translateY(6px);
81
left: 13px;
82
color: rgba(255, 255, 255, 0.5);
83
-webkit-transition: all 0.25s ease;
84
transition: all 0.25s ease;
85
-webkit-backface-visibility: hidden;
86
pointer-events: none;
87
font-size: 22px;
88
}
89
label .req {
90
margin: 2px;
91
color: #1ab188;
92
}
93
94
label.active {
95
-webkit-transform: translateY(50px);
96
transform: translateY(50px);
97
left: 2px;
98
font-size: 14px;
99
}
100
label.active .req {
101
opacity: 0;
102
}
103
104
label.highlight {
105
color: #ffffff;
106
}
107
108
input, textarea {
109
font-size: 22px;
110
display: block;
111
width: 100%;
112
height: 100%;
113
padding: 5px 10px;
114
background: none;
115
background-image: none;
116
border: 1px solid #a0b3b0;
117
color: #ffffff;
118
border-radius: 0;
119
-webkit-transition: border-color .25s ease, box-shadow .25s ease;
120
transition: border-color .25s ease, box-shadow .25s ease;
121
}
122
input:focus, textarea:focus {
123
outline: 0;
124
border-color: #1ab188;
125
}
126
127
textarea {
128
border: 2px solid #a0b3b0;
129
resize: vertical;
130
}
131
132
.field-wrap {
133
position: relative;
134
margin-bottom: 40px;
135
}
136
137
.top-row:after {
138
content: "";
139
display: table;
140
clear: both;
141
}
142
.top-row > div {
143
float: left;
144
width: 48%;
145
margin-right: 4%;
146
}
147
.top-row > div:last-child {
148
margin: 0;
149
}
150
151
.button {
152
border: 0;
153
outline: none;
154
border-radius: 0;
155
padding: 15px 0;
156
font-size: 2rem;
157
font-weight: 600;
158
text-transform: uppercase;
159
letter-spacing: .1em;
160
background: #1ab188;
161
color: #ffffff;
162
-webkit-transition: all 0.5s ease;
163
transition: all 0.5s ease;
164
-webkit-appearance: none;
165
}
166
.button:hover, .button:focus {
167
background: #179b77;
168
}
169
170
.button-block {
171
display: block;
172
width: 100%;
173
}
174
175
.forgot {
176
margin-top: -20px;
177
text-align: right;
178
}
index.js
JavaScript
1
43
43
1
$('.form').find('input, textarea').on('keyup blur focus', function (e) {
2
3
var $this = $(this),
4
label = $this.prev('label');
5
6
if (e.type === 'keyup') {
7
if ($this.val() === '') {
8
label.removeClass('active highlight');
9
} else {
10
label.addClass('active highlight');
11
}
12
} else if (e.type === 'blur') {
13
if( $this.val() === '' ) {
14
label.removeClass('active highlight');
15
} else {
16
label.removeClass('highlight');
17
}
18
} else if (e.type === 'focus') {
19
20
if( $this.val() === '' ) {
21
label.removeClass('highlight');
22
}
23
else if( $this.val() !== '' ) {
24
label.addClass('highlight');
25
}
26
}
27
28
});
29
30
$('.tab a').on('click', function (e) {
31
32
e.preventDefault();
33
34
$(this).parent().addClass('active');
35
$(this).parent().siblings().removeClass('active');
36
37
target = $(this).attr('href');
38
39
$('.tab-content > div').not(target).hide();
40
41
$(target).fadeIn(600);
42
43
});
Advertisement
Answer
add float: right to your content. In your css change form class as below
JavaScript
1
11
11
1
.form {
2
float: right;
3
background: rgba(19, 35, 47, 0.9);
4
padding: 40px;
5
max-width: 600px;
6
margin: 40px auto;
7
border-radius: 4px;
8
box-shadow: 0 4px 10px 4px rgba(19, 35, 47, 0.3);
9
margin-right: 20px; /*what ever you want*/
10
}
11