2

コンテンツがトップバーの下の中央に配置されるように、マップ、ロゴ、およびボタンを中央に配置したいと考えています。

ここに画像の説明を入力

いろいろ試してみたのですが、divを作るとマップが縮小してしまいます。以下は、HTML、SVG データを除外したものです。

<!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>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Free classifieds</title><link rel="icon" href="/img/favicon_us.ico?51340" type="image/x-icon">
<link href="/static/india_files/index_in.css?234" rel="stylesheet" type="text/css">   
    <link rel="stylesheet" type="text/css" href="/static/usa.css?{{VERSION}}" />

</head>

<body>


<div class="topbar">
        <div class="topbar-inner nohistory">
            <div class="topbar-left">
            <a class="topbar-new" href="https://www.koolbusiness.com/account/create"><strong>New!</strong> All your ads and saved searches in one place, create an account today!</a>

            </div>
            <div class="topbar-right">
                <a class="topbar-login last" href="/login" title="Login to your account" rel="nofollow">
                        <i class="sprite_common_topbar_log-in topbar-float_left"></i>


                        {% if loggedin %}<a href="/logout">{% trans %}Log out{% endtrans %}{% else %}<a href="/login">{% trans %}Log in{% endtrans %}{% endif %}




                    </a>
                    <a class="topbar-create first" href="/create/" title="Create your account" rel="nofollow">  
                        <i class="sprite_common_topbar_logged-in topbar-float_left"></i>
                        {% if loggedin %}{{user.name}}{% else %}<a href="/create/">{% trans %}Create account{% endtrans %}</a>{% endif %}



                    </a>

            </div>
        </div>
    </div>


<div onselectstart="return false;" class="unselectable" >
<div id="wrapper">

<h1 id="logo" class="sprite_index_in_in_en_logo spritetext">hipheap.com - The right choice for buying &amp; selling in usa</h1>



    <div id="post">
 <a href="/ai" id="ad">Post your ad for free</a>

</div>


    <!-- map code -->
    <div id="map_base">

    <span class="tip" id="tip"></span>

<!-- the svg code starts here -->
<svg version="1.1" id="map" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 1080 720" xml:space="preserve">

<g id="shadow">
    ...
</g>
</svg>
</div>
<div class="clear"></div>

</div>
</div>

</body>
</html>

CSS は大きすぎて SO の質問に収まりませんが、リンクから入手できます。もちろん、問題のフィドルでは問題が表示されないため、問題のフィドルの作成には役立ちません。

http://jsfiddle.net/niklasro/yyPsW/

何ができるでしょうか?コンテンツの一部を中心に、非常に単純なことをしたいだけですが、これらすべてのフレームワークと cSS と無意味なモジュール化により、単純なことを行うことができなくなりました。

アップデート

div で使用margin: 0 auto;してみましたが、CSS では簡単なことを行うことができないため、機能しません。

4

3 に答える 3

0

まあ、あなたのものはそれより少し複雑です。

まず、あなたのために:

<div id="wrapper">

加える:

margin: 0 auto;

これにより、そのラッパー内で要素が中央に配置されます。はい。ただし、次の絶対位置設定もいくつかあります。

 <div id="post">

削除する必要があります。そうしないと、ボタンが整列しません。

次に、マップに SVG グラフィックを使用しています。したがって、別の CSS プロパティを追加する必要があります。

あなたのための:

 <div id="map_base">

加える:

 margin: 0 auto;

次に、svg グラフィックの場合、以下を追加する必要があります。

 margin-left: 25%; 
于 2013-06-12T18:48:42.253 に答える
0

ロゴ、マップ、ボタンを でラップし、<div>スタイルを設定しますmargin: 0 auto;

margin: 0 autoコンテンツをページの中央に配置するトリックです。

于 2013-06-12T18:41:58.470 に答える