domingo, 23 de septiembre de 2012

Filled Under: ,

Triángulos CSS – Hosting – Forex

Este es un sistema muy básico para conseguir generar un triángulo. Todo se basa en el particular comportamiento de los bordes en CSS, que se muestran aunque su contenido sea nulo o dicho de otra forma, de tamaño cero.

Comenzamos viendo que los bordes se añaden por defecto al tamaño de la caja que rodean y que su color puede ser individualizado. Para ello, las propiedades de color, estilo y ancho las definimos por separado. El orden de los valores de cada propiedad es el habitual, esto es, arriba, derecha, abajo e izquierda.

.t1 {
margin:0 auto;
width:400px;
height:80px;
border-color:red blue yellow green;
border-style:solid;
border-width:10px;
}

...

div class="t1"TEXTO/div



Esta caja tiene 400px de ancho, pero con los dos bordes de 10px ocupa un total de 420px. Con el alto ocurre lo mismo y por eso tiene en total 100px.


Y ahora observad lo que ocurre cuando el ancho y alto de la caja lo hacemos igual a cero. Bueno, antes de nada añadimos undisplay:block; porque de lo contrario lo que veríamos sería nada:

.t2 {
display:block;
margin:0 auto;
width:0;
height:0;
border-color:red blue yellow green;
border-style:solid;
border-width:10px;
}



Pues eso es. Vemos sólo los bordes y cada uno tienen un ancho de 10px que es lo que antes indicamos. Fijaos que al igual que pasaba anteriormente cuando había un tamaño para la caja, los bordes forman un bisel en la zona dónde se cruzan. Ese corte sirve para obtener cuatro triángulos, en este caso cada uno de un color distinto.

Para hacer triángulos de mayor tamaño sólo tenemos que aumentar el ancho del borde:

.t3 {
display:block;
margin:0 auto;
width:0;
height:0;
border-color:red blue yellow green;
border-style:solid;
border-width:60px;
}



Y entendido esto ahora viene la parte más fácil, extraer un triángulo u otras formas a partir de ese cuadrado formado por cuatro triángulos. Si algún color se repite u otros se hacen transparentes, obtendremos diferentes formas. Por ejemplo, esto es lo que se vería si arriba y abajo damos color negro y los otros dos los hacemos transparentes:

.t4 {
display:block;
margin:0 auto;
width:0;
height:0;
border-color:black black tranparent transparent;
border-style:solid;
border-width:60px;
}


¿Y si sólo damos color a la parte izquierda?

.t5 {
display:block;
margin:0 auto;
width:0;
height:0;
border-color:transparent tranparent transparent blue;
border-style:solid;
border-width:60px;
}



La manera de añadir estos triángulos a cualquier otra forma es relativamente fácil. En el siguiente ejemplo creamos una caja (rectangular) con un texto y a continuación un triángulo. Este último por el flujo normal del código, se situaría en la línea siguiente por debajo del rectángulo.

Para colocarlo dónde queremos le añadimos unposition:relative a la caja principal para podermover luego el triángulo a dónde nos interese con unposition:relative,top yleft. El punto de origen con esta combinación (absolute dentro derelative) será la esquina superior izquierda del rectángulo.

.rectangulo {
position:relative;
display:block;
width:200px;
height:40px;
padding:4px 10px 0px 18px;
background:green;
color:white;
text-align:center;
}
.t6 {
position:absolute;
top:-8px;
left:220px;
display:block;
width:0;
height:0;
border-color:transparent transparent transparent green;
border-style: solid;
border-width: 30px;
}

div class="rectangulo"
Rectángulo+Triángulo =Flecha
div class="t6"/div
/div


Rectángulo+Triángulo =Flecha


También le podemos añadir adicionalmente a la izquierda un segundo triángulo del mismo color que el fondo para conseguir una terminación distinta.

.t7 {
position:absolute;
top:2px;
left:0px;
display:block;
width:0;
height:0;
border-color:transparent transparent transparent black;
border-style: solid;
border-width: 20px;
}

div class="rectangulo"
Rectángulo+Triángulo =Flecha
div class="t6"/div
div class="t7"/div
/div

Rectángulo+Triángulo =Flecha


De esta manera podemos combinar triángulos apuntando hacia arriba, hacia la derecha, etc., pero también en diagonal haciendo opacos o transparentes dos contiguos como hicimos con la figura negra a la que le pusimos la clase.t4.

O usar la mitad de esos si ocultamos parte tras la capa principal como hicimos con lasbandas decorativas. En esa entrada también podéis ver cómo agregar formas con:after y:before.

Con otras combinaciones y añadiendo otras propiedades CSS (aquí conborder-radius) podemos hacer otras cositas; pero esa es otra historia...

.t8 {
display:block;
margin:0 auto;
width:0;
height:0;
border-color:transparent darkblue transparent darkblue;
border-style:solid;
border-width:60px;
border-radius:60px;
}



Para terminar, también podemos hacer triángulos no equiláteros individualizando el ancho del borde, aunque si al menos no los hacemos iguales dos a dos, los resultados serán algo complicados de imaginar previamente.

Dos opuestos iguales para obtener isósceles:

.t9 {
display:block;
margin:0 auto;
width:0;
height:0;
border-color:red blue yellow green;
border-style:solid;
border-width:40px 80px 40px 80px;
}



Y todos distintos para escalenos:

.t10 {
display:block;
margin:0 auto;
width:0;
height:0;
border-color:red blue yellow green;
border-style:solid;
border-width:120px 60px 40px 160px;
}



Por último un ejemplo de forma compuesta con dos triángulos, creando el segundo con:after:

.t11 {
position: relative;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 80px solid red;
}
.t11:after {
content:"";
position: absolute;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 80px solid red;
margin: 30px 0 0 -50px;
}

Donate Car To Charity CALIFORNIA DONATE CAR FOR TAX CREDITDONATE CARS IN MADONATE YOUR CAR SACRAMENTOHOW TO DONATE A CAR IN CALIFORNIA DONATE YOUR CAR FOR KIDS,CAR INSURANCE QUOTES COLORADO ,NUNAVUT CULTURE,DAYTON FREIGHT LINESHARDDRIVE DATA RECOVERY SERVICES,DONATE A CAR IN MARYLAND,MOTOR REPLACEMENTS,CHEAP DOMAIN REGISTRATION HOSTING,DONATING A CAR IN MARYLANDNos ofrece Mundial Football eloan com, FIFA World Cupuna gran variedad para contratar mesothelioma info y obtener un equity line of credit y una buena estructura de negocio SEO consolidate loans y visitar su casa matriz Mesothelioma law firm,home equity loans domain name searchSelling annuity payments for cash,Sell my structured settlement,Sell structured settlement,Structured settlement,Structured settlement companies,Sell my annuity payments lump sum,Car accident lawyer Denver,Accident injury attorneys,Sell my annuity

Donate Car To Charity CALIFORNIA DONATE CAR FOR TAX CREDITDONATE CARS IN MADONATE YOUR CAR SACRAMENTOHOW TO DONATE A CAR IN CALIFORNIA DONATE YOUR CAR FOR KIDS,CAR INSURANCE QUOTES COLORADO ,NUNAVUT CULTURE,DAYTON FREIGHT LINESHARDDRIVE DATA RECOVERY SERVICES,DONATE A CAR IN MARYLAND,MOTOR REPLACEMENTS,CHEAP DOMAIN REGISTRATION HOSTING,DONATING A CAR IN MARYLAND

Best social media platforms for business Live casino DUI lawyer Seo services mesothelioma litigation Service business software Psychic for Free pharmacist jobs in chicago cash out annuity mesothelioma drug accident attorneys orange county Social media management WordPress themes for designers Make money online Australia Hire php programmers mesothelioma lawsuits Psd to html Online casino caraccidentlawyer Criminal lawyer st louis mesothelioma attorney Mesothelioma Law Firm Structures Annuity Settlement WORLD TRADE CENTER FOOTAGE Data Recovery Raid Best criminal lawyer in Arizona Criminal defense lawyer CHEAP DOMAIN REGISTRATION HOSTING Italian cooking school AUTO ACCIDENT ATTORNEY Best Seo company Photo Christmas cards Mobile casino mesothelioma symptoms tennessee mesothelioma lawyer workers compensation lawyer los angeles google adsense Car Insurance in South Dakota compare life assurance LOW CREDIT LINE CREDIT CARDS asbestos lawyers Hire php developer ONLINE COLLEDGES Php programmers for hire low credit line credit cards CAR INSURANCE QUOTES COLORADO mesothelioma trial attorney injury lawyers west palm beach car insurance companies Donate a Car in Maryland Casino Mortgage Adviser Hard drive Data Recovery Services online motor insurance quotes structured settlement investments Donate Cars Illinois Tech school Casino reviews Car insurance quotes pa Custom WordPress theme designer Social media platforms for business Paperport Promotional Code mesothelioma law firms mesothelioma attorneys Business finance group Massage School Dallas Texas Best social media platforms Hire php developers yahoo web hosting structured settlement annuity companies cheap domain registration hosting Html email Dwi lawyer seattle mesothelioma lawyer Best Criminal Lawyers in Arizona car insurance in south dakota DONATE YOUR CAR SACRAMENTO mesothelioma help Online Criminal Justice Degree car accident lawyer michigan WebEx costs automobile accident attorney mortgage adviser CAR INSURANCE IN SOUTH DAKOTA Register free domains Php programmers Bankruptcy lawyer mesothelioma attorney directory Home Phone Internet Bundle Business management software Donate Car to Charity California data recovery raid Computer science classes online Paperport promotional code Low Credit Line Credit Cards Social media strategies Donating used cars to charity Neuson Donating a Car in Maryland Seo companies mesotheloma accident attorney san bernardino mesothelioma lawyer texas DONATE CARS ILLINOIS georgia truck accident lawyer World trade center footage New social media platforms Forensics online course structured settlement cash out adverse remortgage verizon sip DONATING USED CARS TO CHARITY massage school dallas texas Car insurance quotes MN HARDDRIVE DATA RECOVERY SERVICES Online Christmas cards car insurance quotes selling annuity dallas mesothelioma lawyer bus accident attorney los angeles Seo company VIRTUAL DATA ROOMS mesothelioma lawyers san diego Donate your car Sacramento criminal defense attorneys florida structured annuity settlement Futuristic Architecture best structured settlement companies Custom Christmas cards WEBEX COSTS sell annuity payment saskatchewan auto insurance semi truck accident lawyers motorcycle accident lawyer san francisco hughes net business Online Colleges WordPress hosting Met Auto Car Insurance Quotes Colorado Psd to WordPress Social media examiner Learning adobe illustrator Nunavut Culture Car Insurance Quotes Utah Forex Trading Platform sell my structured settlement att call conference personal injury solicitor small business administration sba Holland Michigan College Insurance Companies Donate Cars in MA Social media platforms FORENSICS ONLINE COURSE Personal Injury Law Firm mesothelioma suit mesothelioma law suits buy gift card Christmas cards Proud Italian cook Mortgage cheap auto insurance in va WordPress theme designers Adobe illustrator classes car accident lawyers west palm beach Social media tools Social media campaigns Cheap Car Insurance for Ladies HOLLAND MICHIGAN COLLEGE Donate Car for Tax Credit Donate Your Car Sacramento Health Records Personal Health Record Car insurance in South Dakota Futuristic architecture Register Free Domains home phone internet bundle miami personal injury lawyer How to Donate A Car in California structured settlements annuities SELL ANNUITY PAYMENT Sell Annuity Payment Donate Your Car for Kids Automobile Accident Attorney better conferencing calls Asbestos Lawyers mesotheliama Car Donate selling my structured settlement World Trade Center Footage structured settlemen Annuity Settlements Dayton Freight Lines ONLINECLASSES Donate your Car for Money Motor Replacements Cheap Domain Registration Hosting Auto Mobile Insurance Quote Criminal Defense Attorneys Florida virtual data rooms Life Insurance Co Lincoln Online Motor Insurance Quotes Online motor insurance quotes DONATING A CAR IN MARYLAND baltimore mesothelioma attorneys average mesothelioma settlement sell structured settlement calculator Online Classes CHEAP CAR INSURANCE IN VIRGINIA canada personals yahoo accident attorney in los angeles