Foundation - 文字對齊



描述

可以透過新增.text-left、.text-right、.text-center.textjustify類來對齊元素文字。在文字對齊類前面放置一個斷點,將使對齊只在該螢幕尺寸或更大尺寸上應用。 例如,.medium-textcenter會將文字對齊到最小螢幕上的左側,但在螢幕尺寸為中等及更大時變為居中。

示例

以下示例演示了在 Foundation 中使用文字對齊

<html>
   <head>
      <title>Text Alignment</title>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/css/foundation.min.css" crossorigin="anonymous">

      <!-- Compressed JavaScript -->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"></script>

   </head>

   <body>
      <p class = "text-left">Foundation is one of the advanced front-end framework
         for designing beautiful responsive websites. It works on all types of
         devices and provides you with HTML, CSS and JavaScript plugins.
      </p>

      <p class = "text-right">Foundation is one of the advanced front-end
         framework for designing beautiful responsive websites. It works on all
         types of devices and provides you with HTML, CSS and JavaScript plugins.
      </p>

      <p class = "text-center">Foundation is one of the advanced front-end
         framework for designing beautiful responsive websites. It works on all
         types of devices and provides you with HTML, CSS and JavaScript plugins.
      </p>

      <p class = "text-justify">Foundation is one of the advanced front-end
         framework for designing beautiful responsive websites. It works on all
         types of devices and provides you with HTML, CSS and JavaScript plugins.
      </p>

      <p class = "medium-text-center">Foundation is one of the advanced front-end
         framework for designing beautiful responsive websites. It works on all
         types of devices and provides you with HTML, CSS and JavaScript plugins.
      </p>

      
      <script>
         $(document).ready(function() {
            $(document).foundation();
         })
      </script>
   </body>
</html>

產出

讓我們執行以下步驟來了解以上給出的程式碼是如何工作的:

  • 將以上給出的 HTML 程式碼另存為typography_text_alignment.html檔案。

  • 在瀏覽器中開啟此 HTML 檔案,顯示的輸出如下所示。

foundation_typography_helpers.htm
廣告
© . All rights reserved.