1

ASP.NET コードの場合:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Requests.aspx.cs" Inherits="Portal.Requests"
    MasterPageFile="Portal.Master" Title="Requests Log" %>

<asp:Content runat="server" ContentPlaceHolderID="MainContentPlaceHolder">
    <div class="block" id="options">
        <h2>
            Requests Log
        </h2>
        <div style="padding: 12px 13px 0px 12px;">
            <asp:Label runat="server" Text="Search :" CssClass="label" />
            <asp:TextBox ID="txtSearch" runat="server" Size="16" CssClass="textbox" />
            <asp:Button ID="btnSearch" CssClass="button" Style="float: right" runat="server"  Text="Search" OnClick="Search" />
        </div>
        <div style="width: 100%; text-align:center; color: #4E1329; font-size: smaller; float:none; display:inline;">
            you can search by acc no and username
        </div>
        <div style="padding-top: 10px; width: 250px; margin-left: auto; margin-right: auto;">
            <asp:GridView ID="requestsGrid" runat="server" AutoGenerateColumns="False" GridLines="Horizontal">
                <Columns>
                    <asp:BoundField DataField="FirstColumn" HeaderText="Who and When" HeaderStyle-Width="120px" />
                    <asp:BoundField DataField="Type" HeaderText="Type" HeaderStyle-Width="40px" />
                    <asp:TemplateField HeaderText="File" HeaderStyle-Width="25px">
                        <ItemTemplate>
                            <asp:LinkButton ID="btnDownload" runat="server" Text=".zip" CommandArgument='<%# Bind("Id") %>'
                                OnClick="Download" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <RowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:GridView>
        </div>
    </div>
</asp:Content>

レンダリング:

<!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>
    Requests Log
</title><link rel="shortcut icon" type="image/ico" href="favicon.ico" /><link rel="icon" href="favicon.ico" type="image/ico" /><link rel="stylesheet" type="text/css" href="Styles/Stylesheet.css" /><meta name="viewport" content="width = device-width, initial-scale = 1, user-scalable = yes" /><meta name="apple-mobile-web-app-capable" content="yes" /></head>
<body>
    <form method="post" action="Requests.aspx" id="ctl01">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTM3NTI0NjYyOQ9kFgJmD2QWAgIDD2QWAgIDD2QWAgIHDzwrABECAA8WBB4LXyFEYXRhQm91bmRnHgtfIUl0ZW1Db3VudAIWZAEQFgAWABYAFgJmD2QWLgIBD2QWBmYPDxYCHgRUZXh0BRI1IGRheXMgYWdvIGJ5IG1hc2lkZAIBDw8WAh8CBQZHVTk5OTlkZAICD2QWAgIBDw8WAh4PQ29tbWFuZEFyZ3VtZW50BQExZGQCAg9kFgZmDw8WAh8CBRI1IGRheXMgYWdvIGJ5IG1hc2lkZAIBDw8WAh8CBQZHVTk5OTlkZAICD2QWAgIBDw8WAh8DBQE4ZGQCAw9kFgZmDw8WAh8CBRI1IGRheXMgYWdvIGJ5IG1hc2lkZAIBDw8WAh8CBQRDQUFSZGQCAg9kFgICAQ8PFgIfAwUCMTJkZAIED2QWBmYPDxYCHwIFEjUgZGF5cyBhZ28gYnkgbWFzaWRkAgEPDxYCHwIFBENBQVJkZAICD2QWAgIBDw8WAh8DBQIxM2RkAgUPZBYGZg8PFgIfAgUSNSBkYXlzIGFnbyBieSBtYXNpZGQCAQ8PFgIfAgUEQ0FBUmRkAgIPZBYCAgEPDxYCHwMFAjE0ZGQCBg9kFgZmDw8WAh8CBRI1IGRheXMgYWdvIGJ5IG1hc2lkZAIBDw8WAh8CBQRDQUFSZGQCAg9kFgICAQ8PFgIfAwUCMTVkZAIHD2QWBmYPDxYCHwIFEjUgZGF5cyBhZ28gYnkgbWFzaWRkAgEPDxYCHwIFBENBQVJkZAICD2QWAgIBDw8WAh8DBQIxNmRkAggPZBYGZg8PFgIfAgUSNSBkYXlzIGFnbyBieSBtYXNpZGQCA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28gYnkgbWFzaWRkAgEPDxYCHwIFBENBQVJkZAICD2QWAgIBDw8WAh8DBQIzMmRkAhQPZBYGZg8PFgIfAgUSMiBkYXlzIGFnbyBieSBtYXNpZGQCAQ8PFgIfAgUEQ0FBUmRkAgIPZBYCAgEPDxYCHwMFAjMzZGQCFQ9kFgZmDw8WAh8CBRIyIGRheXMgYWdvIGJ5IG1hc2lkZAIBDw8WAh8CBQRDQUFSZGQCAg9kFgICAQ8PFgIfAwUCMzRkZAIWD2QWBmYPDxYCHwIFEXllc3RlcmRheSBieSBtYXNpZGQCAQ8PFgIfAgUGR1U5OTk5ZGQCAg9kFgICAQ8PFgIfAwUCMzVkZAIXDw8WAh4HVmlzaWJsZWhkZBgBBSljdGwwMCRNYWluQ29udGVudFBsYWNlSG9sZGVyJHJlcXVlc3RzR3JpZA88KwAMAQgCAWR+8m8SIKqbNyNbkrQBusmcNv8bCI0kMOXnKhs2eQPoUA==" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['ctl01'];
if (!theForm) {
    theForm = document.ctl01;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<script src="/WebResource.axd?d=QZPkRLZ3fUaN6VLGec8U1eb-7A0RmvYeX7AOUpyZg60IpqTruzWtehyWdkhkl9lfeQb8mEYo0i4n5nosbE2UTMyeu9sobarSJxcUx83SFPs1&amp;t=634768237750540983" type="text/javascript"></script>


<script src="/ScriptResource.axd?d=gH6INTDR0ghdGy8187seiZld9-3hIDEUD4UZXxgbQNevT34BY6bPtKCTN86kvXWivVi5j4Mqk82c9kJeg-HGZ1gkOzd2OkB_H1SFfAw8T0nkn2J_yq_n7Tko8qp8GK6S2sFuEB6V36qw4i4I9UtNBZbY8gEyl8T9hpNAHBP1Ncc0EIlDqB6rGCKHSEZk0IqO0&amp;t=ffffffff940d030f" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>

<script src="/ScriptResource.axd?d=SZ7Iu2p7Dx3sirGc0eodEyXdoKWQbBb85Myy8mEmJcXjSVSUbobpetDKV_2kbrQbyRsPhW2vufjIr6XDGEt7v-ukuTFQq2fNuNOHhcfIHAnmuQRWEXvmSJLpONklLNI8hQI7wxVjfx7Qg6EKoJkMvo4NWxeD_ZHIemwcs1W1QwmKgcv6UKwwzLFcarl9GeoC0&amp;t=ffffffff940d030f" type="text/javascript"></script>
<div class="aspNetHidden">

    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWGQKutYr8AwLI4arfCwLM08eUAgLIs/LdCwL5l4+IBwKqhYmXBwLjpMWIAgLsw7D4AQKN7v/UCQLu7ta3DALHv6LwCwKV16SoBwLup/DgBgLHs/78AwL4l5unDwKphZW2DwLipNGnCgLrw7yXCgKM7ov0AQLt7uLWBALGv66PBAKT17BRAuyn/AkCxbOKpg0C9pen0AiNJ9hTWsRav+IvckroC8qB9LGJ+gh+z0AvBqjhxR2QQA==" />
</div>
    <script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ctl00$ScriptManager1', 'ctl01', [], [], [], 90, 'ctl00');
//]]>
</script>

    
    <div id="header" style="text-align:center;padding-top:5px;"> 
        <img id="uaLogo" alt="UA Logo" src="../UALogo.png" />
    </div>

    
    <div id="wrapper">
        
    <div class="block" id="options">
        <h2>
            Requests Log
        </h2>
        <div style="padding: 12px 13px 0px 12px;">
            <span class="label">Search :</span>
            <input name="ctl00$MainContentPlaceHolder$txtSearch" type="text" id="MainContentPlaceHolder_txtSearch" class="textbox" Size="16" />
            <input type="submit" name="ctl00$MainContentPlaceHolder$btnSearch" value="Search" id="MainContentPlaceHolder_btnSearch" class="button" style="float: right" />
        </div>
        <div style="width: 100%; text-align:center; color: #4E1329; font-size: smaller; float:none; display:inline;">
            you can search by acc no and username
        </div>
        <div style="padding-top: 10px; width: 250px; margin-left: auto; margin-right: auto;">
            <div>
    <table cellspacing="0" rules="rows" border="1" id="MainContentPlaceHolder_requestsGrid" style="border-collapse:collapse;">
        <tr>
            <th scope="col" style="width:120px;">Who and When</th><th scope="col" style="width:40px;">Type</th><th scope="col" style="width:25px;">File</th>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>GU9999</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_0" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl02$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>GU9999</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_1" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl03$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_2" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl04$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_3" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl05$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_4" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl06$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_5" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl07$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_6" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl08$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_7" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl09$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_8" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl10$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_9" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl11$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_10" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl12$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>5 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_11" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl13$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_12" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl14$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_13" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl15$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_14" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl16$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_15" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl17$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_16" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl18$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_17" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl19$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_18" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl20$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_19" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl21$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>2 days ago by masi</td><td>CAAR</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_20" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl22$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr><tr align="center" valign="middle">
            <td>yesterday by masi</td><td>GU9999</td><td>
                            <a id="MainContentPlaceHolder_requestsGrid_btnDownload_21" href="javascript:__doPostBack(&#39;ctl00$MainContentPlaceHolder$requestsGrid$ctl23$btnDownload&#39;,&#39;&#39;)">.zip</a>
                        </td>
        </tr>
    </table>
</div>
        </div>
    </div>

    </div>

    


    
    </form>
</body>
</html>

css:

.block
{
    margin: 0 auto;
    width: 440px;
    background-color: #FAFAFA;
    border-radius: 6px;
    box-shadow: 3px 3px 3px #888888;
    padding-bottom: 10px;
    border: 1px solid #4e1329;
}

.block > *
{
    position: relative;
}

#options
{
    width: 273px;
    height: auto;
}

私は得る:

ここに画像の説明を入力

ラベル/div (両方を試しました) が中央に表示されないのはなぜですか?

4

4 に答える 4

2

変化する:

<div style="text-align:center; color: #4E1329; font-size: smaller; float:none">
    you can search by acc no and username
</div>

<div style="width: 100%; text-align:center; color: #4E1329; font-size: smaller; display:inline;">
    you can search by acc no and username
</div>

注:インラインスタイルではなく、CSSクラスの使用を検討することもできます。

編集:編集内容を確認したら、クラスblockで幅を設定する必要があります。テキストを中央に配置できるようにするには、幅を100%にする必要があります。100%の幅が機能するためには、幅のある親が必要です。ブロックに幅がある場合は、CSSを投稿してください。

編集-最終改訂:

display:inline今それを混乱させています。これとfloat:none;削除する必要があります。

<div style="width: 100%; text-align:center; color: #4E1329; font-size: smaller;">
    you can search by acc no and username
</div>

フィドルの例: http: //jsfiddle.net/QCvaP/1/

于 2012-12-13T11:03:02.040 に答える
0

両方の div は別々で、上の​​ div にはパディングがあります。以下のdivにもパディングを追加してみてください

style ="padding: 12px 13px 0px 12px;text-align:center;"

これがうまくいくことを願っています。

于 2012-12-13T11:11:48.203 に答える
0

あなたの Div には 1 つのインライン CSS があり、あなたの div はdisplay:inline. これは何か特別な理由がありますか?同じものを削除すると、Divが中央揃えになることがわかります。

http://jsfiddle.net/7gdnH/1/

于 2012-12-13T11:44:51.833 に答える
0

周囲のdivと関係があるようです。固定の with でその周りに div を配置すると、すべて問題ないように見えます。

HTML:

<div style="width: 300px; border: 1px solid red;">
    <div style="padding: 12px 13px 0px 12px;">
        <span class="label">Search :</span>
        <input name="ctl00$MainContentPlaceHolder$txtSearch" type="text" id="MainContentPlaceHolder_txtSearch" class="textbox" Size="16" />
        <input type="submit" name="ctl00$MainContentPlaceHolder$btnSearch" value="Search" id="MainContentPlaceHolder_btnSearch" class="button" style="float: right" />
    </div>
    <div style="text-align:center; color: #4E1329; font-size: smaller; float:none">
        you can search by acc no and username
    </div>
</div>    ​

フィドル: http://jsfiddle.net/2c37L

于 2012-12-13T11:10:04.167 に答える