Como ajustar el ancho de las capas

Hola:
Estoy intentando hacer una página aspx en la que hay 5 capas
1 superior, 1 inferior formando una cabecera y un pie
las otras tres van entre estas una al lado de la otra (como cilumnas)
las capas de los exremos llevan treeviews que hacen que su ancho varíe en función del contenido y quiero que la capa central se ajuste al ancho que le quede libre.
¿como puedo hacerlo?
Gracias

1 respuesta

Respuesta
1
Estas capza, ¿cómo estan contenidas? Son tablas o div'¿s? Necesitaria que expliques un poco mejor como estácrontruido el sitio.
Este es mi código aspx, de momento.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmGestionIncendios.aspx.cs" Inherits="Paginas_Default2" %>
<!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 runat="server">
<title>Página sin título</title>
<script language="javascript" src="../JScript/FunVentanas.js" type="text/javascript"></script>
<script language="javascript" src="../JScript/Utilidades.js" type="text/javascript"></script>
<script type="text/javascript">
function Dimensionar()
{
DivCentral.style.width = document.getElementById("GestionIncendios").style.width - document.getElementById("DivIncendios").style.width - document.getElementById("DivBases").style.width;
}
</script>
</head>
<!--
<body onresize=PosicionaDivsGestionIncendios(DivIncendios,DivCentral,DivBases);>
-->
<body>
<form id="GestionIncendios" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePartialRendering="True" />
<!--CABECERA-->
<div runat="server" id="CIzda" style="float:left; width:48%; height: 70px;"
align="left">
<asp:ImageButton runat="server"
ID="ImageButton2" AlternateText="Nuevo Incendio" BorderStyle="Solid"
ImageUrl="~/Imagenes/llama03.ico" ToolTip="Nuevo Incendio"></asp:ImageButton>
</div>
<div runat="server" id="CDcha"
style="float:left; top:0px; width:50%; height: 70px;" align="right">
<asp:ImageButton ID="btnAsignarMedioIncendio" runat="server"
AlternateText="Asignar Medio al Incendio" BorderStyle="Solid"
ImageUrl="~/Imagenes/Foca.ico"
onclick="btnAsignarMedioIncendio_Click" />
</div>
<!--CUERPO CENTRAL-->
<div>
<div runat="server" id="DivIncendios"
style="float:left; width:20%; background-color:#D4E6EA; clear: both;"
align="left">
<asp:UpdatePanel ID="UpdatePanelIncendios" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:TreeView ID="tvwIncendios" runat="server" NodeIndent="10" ShowCheckBoxes="Parent"
ToolTip="Incendios y medios asignados" ShowLines="True"
ontreenodecheckchanged="tvwIncendios_TreeNodeCheckChange">
<ParentNodeStyle Font-Bold="True" Font-Names="Arial Narrow" Font-Size="Large" />
<LevelStyles>
<asp:TreeNodeStyle Font-Names="Arial Narrow" Font-Size="Medium"
Font-Underline="False" />
</LevelStyles>
<RootNodeStyle Font-Bold="True" Font-Names="Arial Narrow" Font-Size="20pt" />
<NodeStyle Font-Bold="False" HorizontalPadding="10px" />
<LeafNodeStyle Font-Names="Arial Narrow" Font-Size="Small" />
</asp:TreeView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerIncendios" EventName="Tick" />
<asp:AsyncPostBackTrigger ControlID="tvwIncendios"
EventName="TreeNodeCheckChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
<div runat="server" id="DivCentral"
style="width: 520px; background-color:Yellow; height: 500px; float: left;">
<asp:MultiView ID="mvwCentral" runat="server">
<asp:View ID="vwAsignarMedioAMision" runat="server" EnableTheming="False">
<table style="width:100%; font-family: Arial; font-size: medium; color: #0000FF;">
<tr>
<td style="font-family: Arial; font-size: medium">
MEDIO</td>
<td>
MISIÓN</td>
<td>
 </td>
</tr>
<tr>
<td>
<asp:ListBox ID="lstMedios" runat="server"></asp:ListBox>
</td>
<td>
<asp:ListBox ID="lstMision" runat="server"></asp:ListBox>
</td>
<td>
 </td>
</tr>
<tr>
<td>
<asp:ImageButton ID="btnAceptar" runat="server" AlternateText="Aceptar"
ImageUrl="~/Imagenes/accept.png" />
<asp:ImageButton ID="btnCancelar" runat="server" AlternateText="Cancelar"
ImageUrl="~/Imagenes/delete.png" />
</td>
<td>
 </td>
<td>
 </td>
</tr>
</table>
</asp:View>
<asp:View ID="vwBase" runat="server">
</asp:View>
<asp:View ID="vwMedioAereo" runat="server">
</asp:View>
<asp:View ID="vwMedioTerrestre" runat="server">
</asp:View>
<asp:View ID="vwBrigada" runat="server">
</asp:View>
</asp:MultiView>
</div>
<div runat="server" id="DivBases"
style="float:right; width:20%; background-color:#D4E6EA;">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TreeView ID="tvwBases" runat="server" NodeIndent="10" ShowCheckBoxes="Leaf"
ToolTip="Bases y medios"
onselectednodechanged="tvwBases_SelectedNodeChanged"
ontreenodecheckchanged="tvwBases_TreeNodeCheckChanged">
<ParentNodeStyle Font-Bold="True" Font-Names="Arial Narrow" Font-Size="Large" />
<LevelStyles>
<asp:TreeNodeStyle Font-Names="Arial Narrow" Font-Size="Medium"
Font-Underline="False" />
</LevelStyles>
<RootNodeStyle Font-Bold="True" Font-Names="Arial Narrow" Font-Size="20pt"
Font-Italic="False" Font-Strikeout="False" />
<NodeStyle HorizontalPadding="10px" Font-Bold="False" />
<LeafNodeStyle Font-Bold="False" Font-Names="Arial Narrow"
Font-Overline="False" Font-Size="Small" Font-Strikeout="False" />
</asp:TreeView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerBases" EventName="Tick" />
<asp:AsyncPostBackTrigger ControlID="tvwBases"
EventName="TreeNodeCheckChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
<!--PIE-->
<div id="DivNoticias" style="background-color:Teal; clear:left; width: 100%; position:absolute; height:20px; border: solid 1px red;" runat="server">
<asp:UpdatePanel ID="UpdatePanelNoticias" runat="server">
</asp:UpdatePanel>
</div>
</div>
<asp:Timer ID="TimerBases" runat="server" Interval="10000"
ontick="TimerBases_Tick">
</asp:Timer>
<asp:Timer ID="TimerIncendios" runat="server" Interval="10000"
ontick="TimerIncendios_Tick">
</asp:Timer>
</form>
</body>
</html>
Lo que yo he usado con anterioridad, aunque no es la forma mas prolija de hacerlo es esto:
<script>
    var sw = screen.width;
    if(sw > 760){
        difsw = (sw - 760)/2 + 'px';
    }
    else{
        difsw = 0;
    }
    document.getElementById('outer-wrapper').style.marginLeft = difsw;
</script>
Reemplaza el outer-wrapper, for la id de la div que quieres cambiar el margin.
Gracias Marcelo, me ha orientado, debiera conocer el ancho de los dos div que tengo a ambos lados pero al ser dinámicos (utilizan %) el valor width no devuelve nada.
No obstante muchas gracias por tu interés y tiempo.
Un fuerte abrazo. Javier.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas