Ca sa aliniati mai multe tag-uri <div> pe aceeasi linie in plan orizontal, puteti folosi aceste doua proprietati CSS: display: inline-block;, sau float (cu valoarea "left", sau "right").
- Pentru un design responsiv, ca elementele <div> sa ramana aliniate si ajustate la lungimea ferestrei browser-ului, folositi valori in procente (%) la lungimea DIV-urilor si margini.


Aliniere elemente Div cu inline-block

In urmatorul exemplu, elementele HTML <div> au proprietatea CSS: display: inline-block;

<!DOCTYPE html>
<html>
<head>
<title>Titlul</title>
<style>
#left, #center, #right {
 position: relative;
 display: inline-block;
 margin: 1em 0.1em 0.1em 0.8%;
 padding: 0.1em;
 background: #ebebfb;
 border: 2px solid blue;
}
#left {
 width: 22%;
 height: 11em;
}
#center {
 width: 52%;
 height: 14em;
}
#right {
 width: 16.2%;
 height: 11em;
}
</style>
</head>
<body>

<div id="left">
 <div>
 <a href="https://coursesweb.net/" title="Web Courses">CoursesWeb.net</a><br/>
 <a href="https://marplo.net/" title="MarPlo.net">MarPlo.net</a><br/>
 <a href="https://gamv.eu/" title="Flash Games">Flash Games</a><br/>
 </div>
</div>

<div id="center">
 <p>Content in the center Div.<br/>
 HTML Course and Tutorials - Align DIVs</p>
</div>

<div id="right">
 Content in the Div from right side.
</div>

</body>
</html>

Exemplu Aliniere cu float

Daca folositi proprietatea CSS float, adaugati un element HTML cu proprietatea "clear: both;" dupa ultimul DIV care are aplicat "float"; astfel aceasta nu va afecta celelalte elemente din pagina care sunt dupa DIV-urile aliniate.

<!DOCTYPE html>
<html>
<head>
<title>Titlul</title>
<style>
#left, #center, #right {
 position: relative;
 float: left;
 margin: 1em 0.1em 0.1em 0.8%;
 padding: 0.1em;
 background: #ebebfb;
 border: 2px solid blue;
}
#left {
 width: 22%;
 height: 11em;
}
#center {
 width: 52%;
 height: 14em;
}
#right {
 width: 16.2%;
 height: 11em;
}
.clr { clear: both; } /* to anulate the effect of the float */
#footer {
 position:relative;
 width: 99%;
 height: 5em;
 margin: 1em auto 0.2em auto;
 background: #befbbe;
}
</style>
</head>
<body>

<div id="left">
 <div>
 <a href="https://coursesweb.net/" title="Web Courses">CoursesWeb.net</a><br/>
 <a href="https://marplo.net/" title="MarPlo.net">MarPlo.net</a><br/>
 <a href="https://gamv.eu/" title="Flash Games">Flash Games</a><br/>
 </div>
</div>

<div id="center">
 <p>Content in the center Div.<br/>
 HTML Course and Tutorials - Align DIVs using float:left;</p>
</div>

<div id="right">
 Content in the right side Div.
</div>
<br class="clr" />

<div id="footer">
 Div under the DIVs aligned with "float: left", after the tag with "clear: both;".
</div>

</body>
</html>

Un Test simplu in fiecare zi

HTML
CSS
JavaScript
PHP-MySQL
Engleza
Spaniola
Ce element HTML adauga continut flash SWF in pagina web?
<object> <div> <script>
<object type="application/x-shockwave-flash" data="file.swf" width="500" height="250">
 <param name="src" value="file.swf" />
 Browser-ul dv. nu suporta SWF.
</object>
Care pseudo-clasa CSS adauga un stil la un camp input de formular cand e cursorul in el?
:active :focus :hover
input:focus {
  background-color: #88fe88;
}
Clic pe instructiunea care transforma un sir JSON in obiect JavaScript.
JSON.stringify(javascript_object) object.toString() JSON.parse(json_string)
var jsnstr = '{"url": "http://coursesweb.net/", "title": "Web Development Courses"}';
var obj = JSON.parse(jsnstr);
alert(obj.url);
Indicati functia PHP care poate crea sau scrie un fisier pe server.
fopen() file_put_contents() file_get_contents()
if (file_put_contents("file.txt", "content")) echo "Fisierul a fost creat";
else echo "Fisierul nu poate fi creat";
Cum se spune "al treilea" in engleza?
threeth third three
I planted the third tree.
- Am plantat al treilea pom.
Cum se spune "al treilea" in spaniola?
segundo tres tercero
Yo planté el tercero árbol.
- Am plantat al treilea pom.
Aliniere DIV-uri pe aceeasi linie

Last accessed pages

  1. Prezentul continuu - Exercitii si teste incepatori (6331)
  2. Prezent perfect si Prezent perfect continuu - Present perfect and Continuous (22174)
  3. Conditional IF - Exercitii si teste engleza incepatori (4215)
  4. Prezentul simplu - Exercitii si teste incepatori (11663)
  5. Exercitii engleza - English Tests and exercises - Grammar (16110)

Popular pages this month

  1. Gramatica limbii engleze - Prezentare Generala (1961)
  2. Prezentul simplu si continuu - Present Tense Simple and Continuous (1343)
  3. Cursuri si Tutoriale: Spaniola, Engleza, HTML, CSS, Php-Mysql, JavaScript, Ajax (959)
  4. Trecutul simplu si continuu - Past Tense Simple and Continuous (942)
  5. Prezent perfect si Prezent perfect continuu - Present perfect and Continuous (879)