(X)HTML, JavaScript, DHTML, XML, CSS Client scripting tehnologije, Dynamic HTML, Cascading Stylesheets, XML i standardi |
|
Alati teme | Način prikaza |
13. 07. 2007. | #1 | |
Psychedelictrance freak
Wrote a book
|
Floating div, u letu ...
Kako da napravim div u letu koji ce da lebdi i da bude ujedno centriran na ekran ? Ja sam probao nesto ovako, za pocetak:
Citat:
1. Kako da centriram div da bude na sredini ekrana ? 2. Kako da postavim div ali bez parenta (testz), da npr moze da se postavi na praznoj stranici ili bar na osnovu body taga ... Hvala, Ivan
__________________
Testiranje bezbednosti web aplikacija |
|
13. 07. 2007. | #2 |
Designer guy
Wrote a book
|
Za centriranje diva na centar po horizontali:
Kôd:
div{ position:absolute; left: 50%; width: 200px; margin-left: -100px; } |
13. 07. 2007. | #3 |
banned
Professional
Datum učlanjenja: 04.06.2005
Poruke: 371
Hvala: 0
738 "Hvala" u 83 poruka
|
Možda
Kôd:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>test</title> <script type="text/javascript"> var centerElement = function(element) { var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; var scrollY = document.documentElement.scrollTop || document.body.scrollTop; var scWidth = function() { var width = -1; var mode = document.compatMode; if(mode || window.ActiveXObject) { switch(mode) { case 'CSS1Compat': width = document.documentElement.clientWidth; break; default: width = document.body.clientWidth; break; } } else { width = self.innerWidth; } return width; }(); var scHeight = function() { var height = -1; var mode = document.compatMode; if((mode || window.ActiveXObject) && (navigator.userAgent.toLowerCase().indexOf('opera') == -1) ) { switch(mode) { case 'CSS1Compat': height = document.documentElement.clientHeight; break; default: height = document.body.clientHeight; break; } } else { height = self.innerHeight; } return height; }(); var elemWidth = element.offsetWidth; var elemHeight = element.offsetHeight; var x = (scWidth - elemWidth) / 2 + scrollX; var y = (scHeight - elemHeight) / 2 + scrollY; element.style.position = 'absolute'; element.style.left = parseInt(x, 10) + 'px'; element.style.top = parseInt(y, 10) + 'px'; }; window.onload = function() { var newDiv = document.createElement('div'); newDiv.id = 'floater'; newDiv.appendChild(document.createTextNode('ovo je test')); document.body.appendChild(newDiv); centerElement(newDiv); } window.onresize = function() { if(document.getElementById('floater')) centerElement(document.getElementById('floater')); } </script> <style> #floater { background-color: #eee; width: 110px; padding: 5px; border: 2px solid #ccc; } </style> </head> <body> </body> </html>
__________________
Don't look at me; I'm lost too. “If you can't dazzle them with brilliance, baffle them with bul*s**t.” |
14. 07. 2007. | #4 |
Psychedelictrance freak
Wrote a book
|
Iskombinovao sam sva tri predloga i nasao resenje za svoj problem ... Hvala!
__________________
Testiranje bezbednosti web aplikacija |
|
|
Slične teme | ||||
Tema | Početna poruka teme | Forum | Odgovori | Poslednja poruka |
Saveti oko MySQL tabela i ovaj put u letu :) narvno | martinluter | Sva početnička pitanja | 2 | 05. 06. 2009. 01:37 |
Smanjenje slike u letu (valjda se tako kaze) | martinluter | Sva početnička pitanja | 21 | 04. 06. 2009. 22:54 |
Kreiranje thumbnail-a web stranice u letu | boccio | PHP | 33 | 24. 12. 2005. 01:29 |