You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: css.html
+32-3Lines changed: 32 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -148,6 +148,22 @@
148
148
font-weight: bolder;
149
149
color: purple;
150
150
}
151
+
#alignExamplediv{
152
+
height:100px;
153
+
border:2px solid gray;
154
+
text-align: center;
155
+
position: relative;
156
+
}
157
+
#alignExampledivp{
158
+
position: absolute;
159
+
top:0;
160
+
bottom:0;
161
+
left:0;
162
+
right:0;
163
+
width:50%;
164
+
height:30%;
165
+
margin: auto;
166
+
}
151
167
</style>
152
168
153
169
<!-- Just for debugging purposes. Don't actually copy this line! -->
@@ -437,9 +453,22 @@ <h2>16. @import</h2>
437
453
<p>ref: be careful while using @import (<ahref="http://www.stevesouders.com/blog/2009/04/09/dont-use-import/">don't use @import</a>)</p>
438
454
</div>
439
455
<divid="something">
440
-
<h2>17. vertical alignment</h2>
441
-
<p><strong></strong></p>
442
-
<p><strong></strong></p>
456
+
<h2>17. vertical Center</h2>
457
+
<p><strong>Question:</strong> How do you align a p center-center inside a div?</p>
458
+
<p><strong>Answer:</strong><code>text-align:center</code>will do the horizontal alignment but <code>vertical-laign:middle</code> will not work here. there are couple of different ways to solve this problem and one of them are positioning. You make the parent as relative position and child as absolute positioning. And then define all position parameter as sero and width 50% and height 30% (sounds messy look at the example and read ref) </p>
0 commit comments