小编DaV*_*iny的帖子

如何在不使用精确位置的情况下从中心缩放图像

我在 html 代码中有一张图片。

当鼠标放在图像上时,我使用 jquery 对其进行缩放 - 但图像从左侧和顶部缩放,我希望它从中心缩放。

我在 stackOverFlow 中搜索,每个人都使用 position attr 但我不使用它。

这是我的示例代码:

<div class="flex-col
Run Code Online (Sandbox Code Playgroud)

<div class="flex-col
Run Code Online (Sandbox Code Playgroud)
let image = $('#navigation_bar img');

$('#menu-item-948').hover(function() {

  //   alert("top :"+position.top +" left : "+ position.left +" right: "+ position.right +" bottom: "+ position.bottom);
  $(image)
    .attr("src", "https://matiloos.dts.company/wp-content/uploads/2018/11/Asset-6.png")
    .animate({
        width: "5rem",
        height: "5rem",
        top: "0.5f",
        left: "0.5f"
      },
      50);
  $('#menu-item-948').append('<p id="text" >text</p>');
  $('#text').css('color', '#55EA00');

}, function() {
  $(image)
    .attr("src", "https://matiloos.dts.company/wp-content/uploads/2018/11/Asset-5.png")
    .animate({
      width: "2.5rem",
      height: "2.5rem"
    }, 300);
  $('#text').remove();
});
Run Code Online (Sandbox Code Playgroud)

我在导航栏中有很多这张图片。

html javascript css jquery

2
推荐指数
1
解决办法
2565
查看次数

如何在嵌套滚动视图中适应包含布局

我在 NestedScrollView 中包含 ConstraintLayout 但遇到问题。\n当布局包含其与父级高度不匹配时。它意味着 ConstraintLayout 的底部到最后一个子视图。

\n\n

这是我的约束布局:

\n\n
 <?xml version="1.0" encoding="utf-8"?>\n\n<android.support.constraint.ConstraintLayout \n xmlns:android="http://schemas.android.com/apk/res/android"\n xmlns:app="http://schemas.android.com/apk/res-auto"\n xmlns:tools="http://schemas.android.com/tools"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:background="@color/background_card"\n android:layoutDirection="ltr">\n\n<ss.com.bannerslider.views.BannerSlider\n    android:id="@+id/image_banner_slider"\n    android:layout_width="match_parent"\n    android:layout_height="250dp"\n    android:adjustViewBounds="true"\n    android:scaleType="centerCrop"\n    app:defaultIndicators="circle"\n    app:interval="7000"\n    app:layout_constraintEnd_toEndOf="parent"\n    app:layout_constraintStart_toStartOf="parent"\n    app:layout_constraintTop_toTopOf="parent"\n    app:loopSlides="true"\n    tools:src="@drawable/horse_banner_1" />\n\n<com.example.davod.a4nal.Custom.CustomFontTextView\n    android:id="@+id/txt_welcome"\n    android:layout_width="wrap_content"\n    android:layout_height="wrap_content"\n    android:layout_marginEnd="16dp"\n    android:layout_marginTop="16dp"\n    android:text="\xd8\xa8\xd9\x87 \xda\x86\xd9\x87\xd8\xa7\xd8\xb1\xd9\x86\xd8\xb9\xd9\x84 \xd8\xae\xd9\x88\xd8\xb4 \xd8\xa2\xd9\x85\xd8\xaf\xdb\x8c\xd8\xaf"\n    android:textColor="@color/text_title_color"\n    android:textSize="@dimen/standard_size_title"\n    app:layout_constraintEnd_toEndOf="parent"\n    app:layout_constraintTop_toBottomOf="@+id/image_banner_slider" />\n\n<Button\n    android:id="@+id/btn_sell_horse"\n    android:layout_width="150dp"\n    android:layout_height="wrap_content"\n    android:layout_marginStart="8dp"\n    android:layout_marginTop="56dp"\n    android:background="@drawable/selector_button_login"\n    android:text="\xd9\x81\xd8\xb1\xd9\x88\xd8\xb4 \xd8\xa7\xd8\xb3\xd8\xa8"\n    android:textSize="@dimen/standard_size_title"\n    app:layout_constraintEnd_toEndOf="parent"\n    app:layout_constraintHorizontal_bias="0.5"\n    app:layout_constraintStart_toEndOf="@+id/btn_request_horse"\n    app:layout_constraintTop_toBottomOf="@+id/txt_welcome" />\n\n<Button\n    android:id="@+id/btn_request_horse"\n    android:layout_width="150dp"\n    android:layout_height="wrap_content"\n    android:layout_marginEnd="8dp"\n    android:layout_marginTop="96dp"\n    android:background="@drawable/selector_button_login"\n    android:text=" \xd8\xaf\xd8\xb1\xd8\xae\xd9\x88\xd8\xa7\xd8\xb3\xd8\xaa \xd8\xa7\xd8\xb3\xd8\xa8"\n    android:textSize="@dimen/standard_size_title"\n    app:layout_constraintEnd_toStartOf="@+id/btn_sell_horse"\n    app:layout_constraintHorizontal_bias="0.5"\n    app:layout_constraintHorizontal_chainStyle="packed"\n    app:layout_constraintStart_toStartOf="parent"\n    app:layout_constraintTop_toBottomOf="@+id/image_banner_slider" />\n\n<Button\n    android:id="@+id/btn_sell_horse_object"\n    android:layout_width="150dp"\n …
Run Code Online (Sandbox Code Playgroud)

android android-layout

1
推荐指数
1
解决办法
2327
查看次数

标签 统计

android ×1

android-layout ×1

css ×1

html ×1

javascript ×1

jquery ×1