0

Webページでテンプレートを使用する方法を学ぼうとしています。stackoverflowで見つけたもののおかげで、基本的なことができました。ここで、フォーマットをある程度制御したいと思います。見栄えの良い例を見つけたので、それを使って何かを学ぼうと思いました。問題が明確になるように、2つの画像を表示します。

オリジナル 私の試み

フォーム自体はあまり気にしません。それは何かを学ぶための例として役立つだけです。私が管理したいことがいくつかあります。1)原文では、会社名がjpeg画像に対して適切に配置されていることに注意してください。私の場合、それは左にくっついています。2)オリジナルでは、Firefoxウィンドウを展開すると、フォームは中央に留まり、両側に空白があります。私の場合、Primefacesコントロールはウィンドウ全体を占めており、高すぎるため、jpeg画像の一部が切り取られています。

オリジナルのusesstyle.cssを見たので、別のアイテムをコピーして貼り付けようとしましたが、探しているコントロールが何も得られませんでした。style.cssで違いを生む唯一のものを紹介します。

body {
margin: 0;
padding: 0;
background: #fff url(images/header.jpg) no-repeat center top;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #7c7c7c;
}

これが元の形の始まりです

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 <title>Xhtml18</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header-wrapper">
    <div id="header">
        <div id="logo">
            <h1><a href="#">Company <span>Name</span></a></h1>
            <p>Nice Slogan Goes Here</p>
        </div>
        <div id="menu">
            <ul>
                <li class="current_page_item"><a href="#">Homepage</a></li>
                <li><a href="#">ABOUT US</a></li>
                <li><a href="#">SERVICES</a></li>
                <li><a href="#">SUPPORT</a></li>
                <li><a href="#">CONTACT</a></li>
            </ul>
        </div>
    </div>
</div>

私はすべての内部定義を入れてみましたが、違いはありませんでした。私のバージョンはずっとシンプルです

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Master template</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</h:head>
<h:body>
<div id="logo">
    <h1><a href="#">Company <span>Name</span></a></h1>
    <p>Nice Slogan Goes Here</p>
</div>
<ui:insert name="AreaOne">Default text</ui:insert>
</h:body>
</html>

最後に、私のxhtmlファイルで、テンプレート作成を可能にする重要なステップを実行します。

<h:body>
<ui:composition template="master.xhtml">
    <ui:define name="AreaOne">

テンプレート作成の主要なポイントが機能しているように見えるように、私はそれをもう少し制御する必要があります。長いメッセージで申し訳ありませんが、問題を説明するためにすべてが必要だと思います。

編集:ファイル自体を追加する方法がわからないので、コードとして詳しく説明します

body {
margin: 0;
padding: 0;
background: #fff url(images/header.jpg) no-repeat center top;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #7c7c7c;
}

h1, h2, h3 {
margin: 0;
padding: 0;
font-weight: normal;
color: #000;
}

h1 {
font-size: 2em;
}

h2 {
font-size: 2.8em;
}

h3 {
font-size: 1.6em;
}

p, ul, ol {
margin-top: 0;
line-height: 180%;
}

ul, ol {
}

a {
text-decoration: none;
color: #419725;
}

a:hover {
}

#wrapper {
margin: 0 auto;
padding: 0;
}

/* Header */

#header-wrapper {
height: 234px;


}

#header {
width: 950px;
margin: 0 auto;
padding: 0px 0px 0px 30px;
}

/* Logo */

#logo {
float: left;
width: 500px;
margin: 0px;
padding: 30px 0px 0px 60px;
color: #f7f7f7;

}

#logo h1, #logo p {
}

#logo h1 {
padding: 0px 0px 0px 0px;
letter-spacing: -1px;
font-size: 3.8em;
background: redc;
}

#logo h1 span {
color: #efc527;
}

#logo p {
margin: 0;
padding: 0px 0px 0px 0px;
font-size: 16px;
color: #fff;
} 

#logo a {
border: none;
background: none;
text-decoration: none;
color: #f7f7f7;
}

/* Search */

#search {
float: left;
width: 280px;
height: 40px;
padding: 0px;
}

#search form {
height: 40px;
margin: 0;
padding: 0px 0 0 10px;
}

#search fieldset {
margin: 0;
padding: 0;
border: none;
}

#search-text {
width: 170px;
padding: 6px 5px 2px 5px;
border: 1px solid #DEDEDE;
background: #FFFFFF;
text-transform: lowercase;
font: normal 11px Arial, Helvetica, sans-serif;
color: #5D781D;
}

#search-submit {
width: 50px;
height: 22px;
border: none;
background: #e4e4e4;
color: #171d21;
}

/* Menu */

#menu {
float: right;
width: 950px;
height: 50px;
margin: 0 auto;
padding: 0;
}

#menu ul {
float: left;
margin: 0;
padding: 74px 0px 0px 0px;
list-style: none;
line-height: normal;
}

#menu li {
float: left;
}

#menu a {
display: block;
margin-right: 1px;
padding: 16px 20px 15px 20px;
text-decoration: none;
text-align: center;
text-transform: uppercase;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #fff;
border: none;
}

#menu a:hover, #menu .current_page_item a {
background: #131618;
text-decoration: none;
color: #FFFFFF;
}

#menu .current_page_item a {
}

/* Page */

#page {
width: 990px;
margin: 0 auto;
padding: 0px 0px 0px 0px;
background: url(images/img03.jpg) repeat-y left top;
}

#page-bgtop {
padding: 40px 0px 20px 0px;
background: url(images/img02.jpg) no-repeat left top;
}
/* Content */

#content {
float: left;
width: 720px;
padding: 0px 0px 0px 0px;
}

.post {
margin-bottom: 40px;
border-bottom: 1px dotted #E7E2DC;
margin-right: 10px;
}

.post .title {
height: 41px;
padding: 7px 0px 0px 30px;
letter-spacing: -.5px;
}

.post .title a {
border: none;
color: #000;
 }

.post .meta {
margin-bottom: 30px;
padding: 0px 30px 0px 30px;
text-align: left;
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
font-weight: bold;
font-style: italic;
}

.post .meta .date {
float: left;
}

.post .meta .posted {
float: right;
}

.post .meta a {
}

.post .entry {
padding: 0px 30px 20px 30px;
padding-bottom: 20px;
text-align: justify;
}

.links {
padding-top: 20px;
font-size: 12px;
font-weight: bold;
}

/* Sidebar */

#sidebar {
float: right;
width: 240px;
margin: 0px;
padding: 0px 20px 0px 10px;
color: #fff;
}

#sidebar ul {
margin: 0;
padding: 0;
list-style: none;
}

#sidebar li {
margin: 0;
padding: 0;
}

#sidebar li ul {
margin: 0px 0px;
padding-bottom: 30px;
}

#sidebar li li {
line-height: 35px;
border-bottom: 1px dotted #E7E2DC;
margin: 0px 30px;
border-left: none;
}

#sidebar li li span {
display: block;
margin-top: -20px;
padding: 0;
font-size: 11px;
font-style: italic;
}

#sidebar li li a {
padding: 0px 0px 0px 15px;
}

#sidebar h2 {
height: 38px;
padding-left: 30px;
letter-spacing: -.5px;
font-size: 1.8em;
color: #fff;
}

#sidebar p {
margin: 0 0px;
padding: 0px 30px 20px 30px;
text-align: justify;
}

#sidebar a {
border: none;
color: #efc527;
}

#sidebar a:hover {
text-decoration: underline;
}

/* Calendar */

#calendar {
}

#calendar_wrap {
padding: 20px;
}

#calendar table {
width: 100%;
}

#calendar tbody td {
text-align: center;
}

#calendar #next {
text-align: right;
}

/* Footer */

#footer {
height: 50px;
margin: 0 auto;
padding: 0px 0 30px 0;
font-family: Arial, Helvetica, sans-serif;
border-top: 5px solid #4ac221;
width: 990px;
background: #262626;
}

#footer p {
margin: 0;
padding-top: 40px;
line-height: normal;
font-size: 9px;
text-transform: uppercase;
text-align: center;
color: #fff;
}

#footer a {
color: #fff;
}
4

1 に答える 1

1

あなたbrackgroundにはcenter属性があります。そのため、中央にロゴがあり、テキストはありません。

body {
margin: 0;
padding: 0;
background: #fff url(images/header.jpg) no-repeat center top;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #7c7c7c;
}

属性を削除するcenterか、そのようなことをしてテキストを移動することができます(単なる例です!)

<div align="center"><h1><a href="#">Company <span>Name</span></a></h1></div>

次に、primefacesのコンポーネントを停止して自動サイズ変更するには、デフォルトのcssをオーバーライドする必要があります。

PanelGridを使用していると思いますので、

<p:panelGrid columns="2" style="width: 200px !important">....</p:panelGrid>

それが必要かどうかはわかりません!importantが、基本的には、コンポーネントの自動サイズ変更を防ぐために、コンポーネントに固定幅を指定する必要があります

編集:

スタイルをすべてのp:panelGridコンポーネントに適用する場合は、cssクラス全体をオーバーライドすることを検討する必要があります。

各primefacesコンポーネントのcssクラス名を知るためにここを見てください:

http://primefaces.googlecode.com/files/primefaces_users_guide_3_2.pdf

于 2012-05-13T09:54:21.327 に答える