# 外部サイトへのDiscourseトピックリストの埋め込みに関するスタイリングと使用の例

**URL:** https://meta.discourse.org/t/examples-of-styling-and-use-of-embedding-a-list-of-discourse-topics-on-a-external-site/130672
**Category:** Support
**Created:** [2019 年 10 月 10 日午前 8:31 UTC](https://meta.discourse.org/t/examples-of-styling-and-use-of-embedding-a-list-of-discourse-topics-on-a-external-site/130672 "2019-10-10T08:31:35Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![adamgpope](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamgpope/32/121658_2.png) [@adamgpope](https://meta.discourse.org/u/adamgpope)
#### Post date: [2021 年 5 月 12 日午後 4:58 UTC](https://meta.discourse.org/t/examples-of-styling-and-use-of-embedding-a-list-of-discourse-topics-on-a-external-site/130672/4 "2021-05-12T16:58:57Z")

</div>

少しいじって、トピックリストの上部に検索バーを追加しました。これで私の埋め込みは以下のようになります：

 ![topics](https://global.discourse-cdn.com/meta/original/4X/6/d/8/6d8996dd6656be12eb64b38a5d2e7a9b633dfeb0.png)

検索フォーム、スタイル、トピックリストのコード：

> **要約**
>
> ```
> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
> <script src="https://adams-discourse.com/javascripts/embed-topics.js"></script>
> <style>
> 
> * {
> box-sizing: border-box;
> }
> 
> #form {
> position:absolute;
> left: 22px;
> top:5px;
> width:55%;
> }
> 
> form.example input[type=text] {
> padding: 10px;
> font-size: 17px;
> border: 1px solid grey;
> float: left;
> width: 80%;
> background: #f1f1f1;
> }
> 
> form.example button {
> float: left;
> width: 19%;
> padding: 10px;
> background:#1e825b;
> color: white;
> font-size: 17px;
> border: 1px solid grey;
> border-left: none;
> cursor: pointer;
> }
> 
> form.example button:hover {
> background: green;
> }
> 
> form.example::after {
> content: "";
> clear: both;
> display: table;
> }
> 
> d-topics-list iframe{
> position:absolute;
> width: 100%!important;
> top:-10px;
> }
> </style>
> 
> </head>
> <body>
> <d-topics-list discourse-url="https://adams-discourse.com" template="complete" category="9" per-page="6" allow-create="true" ></d-topics-list>
> <div id="form">
> <form class="example" action="https://adams-discourse.com/search?q=" target="_blank">
> <input placeholder="このフォーラムを検索" aria-label="このフォーラムを検索" type="text" id="q" name="q" value="">
> <button type="submit"><i class="fa fa-search"></i></button>
> </form> </div>
> 
> ```

ボックスレイアウトを実現するために、Discourse の埋め込み CSS では `grid` の代わりに `flex` を使用しました。

> **要約**
>
> ```
> .topics-list {
> display: inline-flex;
> flex-wrap: wrap;
> padding: 8px 8px 0 8px;
> margin: 3px 3px 0 0;
>   
> .topic-list-item .main-link {
> border: 1px solid gray;
> margin: 5px;
> width: 250px;
> height: 90px;
> }
>   
> .topic-column-wrapper {
> flex-direction: column-reverse;
>       
> .topic-column.details-column {
> width: 100%;
> }
> 
> .topic-created-at {
> padding-left: 0!important;
> font-size:13px;
> }
> 
> .topic-column.featured-image-column .topic-featured-image img {
> display:none;
> }
> }
> }
> 
> .new-topic-btn {
> float: left;
> margin: 16px 0 0 58%;
> height: 40.5px;;
> background:#1e825b;
> }
> .new-topic-btn:hover {
> background: rgb(73, 130, 5);
> }
> 
> ```

---

_[View the full topic](https://meta.discourse.org/t/examples-of-styling-and-use-of-embedding-a-list-of-discourse-topics-on-a-external-site/130672)._
